Solved

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

Posted on 1998-08-07
10
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

690 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