Solved

How to create a new image on Picturebox in a MDIForm ?

Posted on 1998-08-07
10
182 Views
Last Modified: 2012-05-04
I call this Sub several times to add new pictures:

Public Sub LäggTillBild(Fil$)
Static XW%, YH%, X%, NyBild() As Image
On Error GoTo LäggTillBild
    ReDim Preserve NyBild(X%)
    Set NyBild(X%) = Image1(0)
    NyBild(X%) = LoadPicture(Fil$)
    If XW + NyBild(X%).Width + 100 > Screen.Width Then _
      YH = YH + NyBild(X%).Height: XW = 0
    NyBild(X%).Left = XW
    NyBild(X%).Top = YH
    NyBild(X%).Visible = True
    XW = XW + NyBild(X%).Width
    NyBild(X%).Tag = Fil$
    X% = X% + 1
    Exit Sub
LäggTillBild:
    MsgBox Error, 16
    Set NyBild(X%) = Nothing
    Exit Sub
End Sub

Why can i just see the last thumbernail loaded ?
How to get scrollbars to the MDIform when i rezize it ?

/Janne, SWEDEN
0
Comment
Question by:jannea
  • 5
  • 4
10 Comments
 

Expert Comment

by:Nusse
ID: 1468278
Tjenare Janne

Hur visar du bilderna? I rad, eller? Har du en egen KÖPT version?



0
 
LVL 1

Author Comment

by:jannea
ID: 1468279
Hej du Nusse !

Som det framgår i koden så fylls en rad och sedan kommer nästa rad med bilder under den första.

Köpt version ? av VB5  eller ja det har jag...
Problemet mitt är att jag inte kan skapa en ny Image för varje gång utan jag gissar att det är samma Image som flyttar på sig. Det är väl därför jag bara ser den sista.

Vet du hur man i kod skapar en ny Image ?

/Janne
0
 
LVL 14

Expert Comment

by:waty
ID: 1468280
Is this in english or other language discussion group?


0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 1

Author Comment

by:jannea
ID: 1468281
Waty, It was Swedish, you are welcome with English....
0
 
LVL 14

Accepted Solution

by:
waty earned 50 total points
ID: 1468282
You always use the same Image1(0) control. Use the new operator to add new images.

NB : Why do you store images in the array? It should be easier to add it directly to controls?

0
 
LVL 1

Author Comment

by:jannea
ID: 1468283
Waty,

How to use the new operator to add new images. ? ,code PLS I can´t Dim NyBild As New Image.

OK I don´t need the array, this was just when I did test some other stuff.
0
 
LVL 14

Expert Comment

by:waty
ID: 1468284
You have to do as following :

Public Sub LäggTillBild(Fil$)

Static XW%, YH%, X% as long

On Error GoTo LäggTillBild

    load Image1(X%)
    Image1(X%) = LoadPicture(Fil$)
    If XW + Image1(X%).Width + 100 > Screen.Width Then _
      YH = YH + NyBild(X%).Height: XW = 0
    Image1(X%).Left = XW
    Image1(X%).Top = YH
    Image1(X%).Visible = True
    XW = XW + Image1(X%).Width
    Image1(X%).Tag = Fil$
    X% = X% + 1

    Exit Sub
LäggTillBild:
    MsgBox Error, 16
    unload Image1(X%)
    Exit Sub

End Sub
0
 
LVL 1

Author Comment

by:jannea
ID: 1468285
Waty, thanks

So now if works better, I know I seen the tecniqe Load 'Image()' before to add new controls.
How aboute the the Q:

How to get scrollbars to the MDIform when i rezize it ?  (See above)

/Janne
0
 
LVL 14

Expert Comment

by:waty
ID: 1468286
To have scrollbar on your MDI, your childs must be out of the current view (part of form or completely).
0
 
LVL 1

Author Comment

by:jannea
ID: 1468287
Ok
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now