Solved

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

Posted on 1998-08-07
10
180 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
 
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

706 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

18 Experts available now in Live!

Get 1:1 Help Now