After Googling myself to death, I have turned to the one place that can usually provide an answer. Why I did not start here I don't know.
Requirements / Desires
VB6
I have a project with
1 picture box named picture1
1 File list box named fileObjects
1 command button
1 usercontrol defined in the project. This control has a pitcture box in it at the moment. I was trying not to use a picture box but to set the picture of the control and thought this might help with the visibility problem after the control is inserted.
Here is what I am trying to accomplish
After choosing a file (File list is a list of gifs in a directory). I want to click the button and have an instance of the user control placed in the forms picture box and assign the user controls picture to be the picture from the list box.
Currently I have tried the controls.add method and the code runs fine but the control is not visible or actually on the form.
I can place the control on the form at design and changes its picture at run time no problem. Getting the control to be visible and moveable after on the form.
Eventually I will be adding an unknown number of these user controls to the form to display what is effectively a layout of objects in a field or in a room. The gifs are pictures of the actuall items.
I need the following example code or help
1. Actually adding the controls to the form at runtime and having them have the ability to get control simply for the purpose of moving them around.
2. I may need some help with the coding of the user control to allow for its ability to be dragged after on the form.
This is my first jump into user controls of this nature. Spent all my programming time in the DB world and business logic/problems solving coding.
So far my coding on my button is this
Dim myControl As VehItem
Set myControl = Controls.Add("project1.VehItem", "VehItem1", Me) 'This will be changed in the future to name it incrementally after I get the first one to work right
Picture1.Picture = LoadPicture(App.Path & "\images\Objects\" & fileObjects.FileName)
Set myControl.Picture = Picture1.Picture
So far my coding in my first user contorl is
Option Explicit
Public Property Set Picture(ByRef newpic As IPictureDisp)
Picture1.Picture = Form1.Picture1.Picture
End Property
Private Sub UserControl_Initialize()
Picture1.Picture = LoadPicture(App.Path & "\images\Vehicles\Truck.gif")
End Sub
Andy Baldwin
"Testing is the most overlooked programming language on the books!
Requirements / Desires
VB6
I have a project with
1 picture box named picture1
1 File list box named fileObjects
1 command button
1 usercontrol defined in the project. This control has a pitcture box in it at the moment. I was trying not to use a picture box but to set the picture of the control and thought this might help with the visibility problem after the control is inserted.
Here is what I am trying to accomplish
After choosing a file (File list is a list of gifs in a directory). I want to click the button and have an instance of the user control placed in the forms picture box and assign the user controls picture to be the picture from the list box.
Currently I have tried the controls.add method and the code runs fine but the control is not visible or actually on the form.
I can place the control on the form at design and changes its picture at run time no problem. Getting the control to be visible and moveable after on the form.
Eventually I will be adding an unknown number of these user controls to the form to display what is effectively a layout of objects in a field or in a room. The gifs are pictures of the actuall items.
I need the following example code or help
1. Actually adding the controls to the form at runtime and having them have the ability to get control simply for the purpose of moving them around.
2. I may need some help with the coding of the user control to allow for its ability to be dragged after on the form.
This is my first jump into user controls of this nature. Spent all my programming time in the DB world and business logic/problems solving coding.
So far my coding on my button is this
Dim myControl As VehItem
Set myControl = Controls.Add("project1.VehItem", "VehItem1", Me) 'This will be changed in the future to name it incrementally after I get the first one to work right
Picture1.Picture = LoadPicture(App.Path & "\images\Objects\" & fileObjects.FileName)
Set myControl.Picture = Picture1.Picture
So far my coding in my first user contorl is
Option Explicit
Public Property Set Picture(ByRef newpic As IPictureDisp)
Picture1.Picture = Form1.Picture1.Picture
End Property
Private Sub UserControl_Initialize()
Picture1.Picture = LoadPicture(App.Path & "\images\Vehicles\Truck.gif")
End Sub
Andy Baldwin
"Testing is the most overlooked programming language on the books!