1
votes

I'm working on a new UI-element in an vb6 programm. I need to place pictures dynamically on 2 diffenent colored background lines:

I tried out two different ideas but none of them is working:

Idea 1

I used image control and assigned an image to the control. Then I set left, top, with and hight properties to values where I want to place the image. Image was places at correct position but not in foregound on a frame but in background (behind coloured frame).

Can anyone tell me how I can place an image control in foreground (on green coloured frame)? I need to place these image controlls dynamically from code in running program.

Idea 2

In second sulution I tried to use picturebox instead of image control. Picturebox can be placed on colored background (frame) without any problems. Here the problem is that loaded picture has to be scaled to size of picturebox picture property. Picture is loaded to picturebox by following code: Picture.Picture = LoadPicture("F:\img.JPG")

Does anyone know how I can scale this img to size of picturebox?

Can anyone help me to follow up one of the solutions. In principle I would prefere to use Image controls if it is polible to place them in foreground on frame.

1

1 Answers

2
votes

I'm going to guess that after creating the image control, you are moving it onto the Frame. If so, this is why the control is behind the Frame. You really want the image to be inside the frame. The key to do this is to set the Container property.

Dim img As Image

Set img = Me.Controls.Add("VB.Image", "Image1")

If Not img Is Nothing Then
   img.Move 200, 200, 400, 400
   img.Stretch = True
   img.Picture = LoadPicture("your image.jpg")
   Set img.Container = Frame1
   img.Visible = True
End If