MKadric
asked on
vb6 create image control (not picturebox) Dynamically
vb6 create image control (not picturebox) Dynamically
Must be a control array.
example
imgSi1(0), imgSi1(1) etc.
Create as many as needed at run time.
The example also must show how to place the image control array inside of another control at run time
EXAMPLE place image control inside picturebox control
I already know how to creat command buttons, text box but I can not seem to get the image code to work and I do not know where to start to put the image control inside of a picturebox control.
Must be a control array.
example
imgSi1(0), imgSi1(1) etc.
Create as many as needed at run time.
The example also must show how to place the image control array inside of another control at run time
EXAMPLE place image control inside picturebox control
I already know how to creat command buttons, text box but I can not seem to get the image code to work and I do not know where to start to put the image control inside of a picturebox control.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Okay you're right, but why do you say "You have to remove the controls added at run time"? Are you confusing that with the fact that when you use Load to create controls that you can only Unload those controls that you created at runtime?
'You also have to remove the controls added at run time using Load Method e.g. in Form_Unload
Private Sub Form_Unload(Cancel As Integer)
Dim nItemCounter As Long
For nItemCounter = Image1.UBound To 1 Step -1
Unload Image1(nItemCounter)
Next
End Sub
@Martin
it should read
You have to remove (destroy) controls created at Runtime e.g. in Form Unload:
it should read
You have to remove (destroy) controls created at Runtime e.g. in Form Unload:
You have to remove (destroy) controls created at Runtime e.g. in Form Unload:Sorry, but that's not true.
Anyway, as a normal clean up.
Sorry, but that's not true.
>Set m_oImgSi1C(i) = Me.Controls.Add("VB.Image"
It's been established as best practice to set all object instances to Nothing explicitly.
Anyway, as a normal clean up.That I can agree to but it can be done at any time and not just at EOJ (that's End Of Job in case I'm the only old timer here:) ).
>Set m_oImgSi1C(i) = Me.Controls.Add("VB.Image", "imgSi1C" & CStr(i), Me.Picture2)
It's been established as best practice to set all object instances to Nothing explicitly.
ASKER
I want to thank all for thier input... this has been a great help.
In the IDE, draw an Image control inside the picturebox and set the image control's Index property to 0 and set it's Visible property to False.
Then when you want to show the first one you of course just set it to Visible. To create others you do something like this
Load Image1(1)
Image1(1).Visible = True
Image1(1).Left = Image1(0).Left + 200