I remember having a user control done for me back in 2009 with the text label that could be changed in the program.
But I am wondering if there is a way to add an ImageBox Control in a control array index of 1 to 20, change the image in the program when prompted, etc.?
I think it's a matter of changing the "LoadLetter" with "LoadImg", and changing the bottom two Public Property areas to replace Caption with Picture or whatever is needed if Picture is ambiguous.
Here is the code in the UserControl I have:
Can anyone please help me in learning how to add an Image Control to the UserControl, and change the image in a UserControl1.Picture control on a form when prompted?
But I am wondering if there is a way to add an ImageBox Control in a control array index of 1 to 20, change the image in the program when prompted, etc.?
I think it's a matter of changing the "LoadLetter" with "LoadImg", and changing the bottom two Public Property areas to replace Caption with Picture or whatever is needed if Picture is ambiguous.
Here is the code in the UserControl I have:
Code:
Option Explicit
'Event Declarations:
Event Click() 'MappingInfo=LoadLetter,LoadLetter,-1,Click
Event MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseDown
Event MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single) 'MappingInfo=UserControl,UserControl,-1,MouseUp
Event WriteProperties(PropBag As PropertyBag) 'MappingInfo=UserControl,UserControl,-1,WriteProperties
Event ReadProperties(PropBag As PropertyBag) 'MappingInfo=UserControl,UserControl,-1,ReadProperties
Private Sub UserControl_Click()
RaiseEvent Click
End Sub
Private Sub UserControl_Initialize()
UserControl.BackStyle = 0
End Sub
'Initialize Properties for User Control
Private Sub UserControl_InitProperties()
End Sub
'Load property values from storage
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
RaiseEvent ReadProperties(PropBag)
' UserControl.MaskColor = m_MaskColor
Set Picture = PropBag.ReadProperty("Picture", Nothing)
UserControl.MaskColor = PropBag.ReadProperty("MaskColor", -2147483633)
Set MaskPicture = PropBag.ReadProperty("MaskPicture", Nothing)
UserControl.ScaleHeight = PropBag.ReadProperty("ScaleHeight", 1065)
UserControl.ScaleLeft = PropBag.ReadProperty("ScaleLeft", 0)
UserControl.ScaleMode = PropBag.ReadProperty("ScaleMode", 1)
UserControl.ScaleTop = PropBag.ReadProperty("ScaleTop", 0)
UserControl.ScaleWidth = PropBag.ReadProperty("ScaleWidth", 1575)
UserControl.ScaleLeft = PropBag.ReadProperty("ScaleLeft", 0)
UserControl.ScaleTop = PropBag.ReadProperty("ScaleTop", 0)
UserControl.ScaleWidth = PropBag.ReadProperty("ScaleWidth", 1575)
UserControl.ScaleHeight = PropBag.ReadProperty("ScaleHeight", 1065)
UserControl.ScaleMode = PropBag.ReadProperty("ScaleMode", 1)
Set Picture = PropBag.ReadProperty("Picture", Nothing)
UserControl.MaskColor = PropBag.ReadProperty("MaskColor", -2147483633)
Set MaskPicture = PropBag.ReadProperty("MaskPicture", Nothing)
UserControl.BackColor = PropBag.ReadProperty("BackColor", &H8000000F)
UserControl.BackStyle = PropBag.ReadProperty("BackStyle", 0)
LoadLetter.Caption = PropBag.ReadProperty("Caption", "W")
End Sub
'Write property values to storage
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
RaiseEvent WriteProperties(PropBag)
Call PropBag.WriteProperty("Picture", Picture, Nothing)
Call PropBag.WriteProperty("MaskColor", UserControl.MaskColor, -2147483633)
Call PropBag.WriteProperty("MaskPicture", MaskPicture, Nothing)
Call PropBag.WriteProperty("ScaleHeight", UserControl.ScaleHeight, 3600)
Call PropBag.WriteProperty("ScaleLeft", UserControl.ScaleLeft, 0)
Call PropBag.WriteProperty("ScaleMode", UserControl.ScaleMode, 1)
Call PropBag.WriteProperty("ScaleTop", UserControl.ScaleTop, 0)
Call PropBag.WriteProperty("ScaleWidth", UserControl.ScaleWidth, 4800)
Call PropBag.WriteProperty("BackColor", UserControl.BackColor, &H8000000F)
Call PropBag.WriteProperty("BackStyle", UserControl.BackStyle, 0)
Call PropBag.WriteProperty("Caption", LoadLetter.Caption, "W")
End Sub
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,ScaleLeft
Public Property Get ScaleLeft() As Single
ScaleLeft = UserControl.ScaleLeft
End Property
Public Property Let ScaleLeft(ByVal New_ScaleLeft As Single)
UserControl.ScaleLeft() = New_ScaleLeft
PropertyChanged "ScaleLeft"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,ScaleTop
Public Property Get ScaleTop() As Single
ScaleTop = UserControl.ScaleTop
End Property
Public Property Let ScaleTop(ByVal New_ScaleTop As Single)
UserControl.ScaleTop() = New_ScaleTop
PropertyChanged "ScaleTop"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,ScaleWidth
Public Property Get ScaleWidth() As Single
ScaleWidth = UserControl.ScaleWidth
End Property
Public Property Let ScaleWidth(ByVal New_ScaleWidth As Single)
UserControl.ScaleWidth() = New_ScaleWidth
PropertyChanged "ScaleWidth"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,ScaleHeight
Public Property Get ScaleHeight() As Single
ScaleHeight = UserControl.ScaleHeight
End Property
Public Property Let ScaleHeight(ByVal New_ScaleHeight As Single)
UserControl.ScaleHeight() = New_ScaleHeight
PropertyChanged "ScaleHeight"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,ScaleMode
Public Property Get ScaleMode() As Integer
ScaleMode = UserControl.ScaleMode
End Property
Public Property Let ScaleMode(ByVal New_ScaleMode As Integer)
UserControl.ScaleMode() = New_ScaleMode
PropertyChanged "ScaleMode"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,Picture
Public Property Get Picture() As Picture
Set Picture = UserControl.Picture
End Property
Public Property Set Picture(ByVal New_Picture As Picture)
Set UserControl.Picture = New_Picture
On Error Resume Next
UserControl.PaintPicture New_Picture, 0, 0
UserControl.Refresh
On Error GoTo 0
PropertyChanged "Picture"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,MaskColor
Public Property Get MaskColor() As Long
MaskColor = UserControl.MaskColor
End Property
Public Property Let MaskColor(ByVal New_MaskColor As Long)
UserControl.MaskColor() = New_MaskColor
PropertyChanged "MaskColor"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,MaskPicture
Public Property Get MaskPicture() As Picture
Set MaskPicture = UserControl.MaskPicture
End Property
Public Property Set MaskPicture(ByVal New_MaskPicture As Picture)
Set UserControl.MaskPicture = New_MaskPicture
PropertyChanged "MaskPicture"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,BackColor
Public Property Get BackColor() As OLE_COLOR
BackColor = UserControl.BackColor
End Property
Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
UserControl.BackColor() = New_BackColor
PropertyChanged "BackColor"
End Property
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=UserControl,UserControl,-1,BackStyle
Public Property Get BackStyle() As Integer
BackStyle = UserControl.BackStyle
End Property
Public Property Let BackStyle(ByVal New_BackStyle As Integer)
UserControl.BackStyle() = New_BackStyle
PropertyChanged "BackStyle"
End Property
Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
RaiseEvent MouseDown(Button, Shift, x, y)
End Sub
Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
RaiseEvent MouseUp(Button, Shift, x, y)
End Sub
'MappingInfo=LoadLetter,LoadLetter,-1,Caption
Public Property Get Caption() As String
Caption = LoadLetter.Caption
End Property
Public Property Let Caption(ByVal New_Caption As String)
LoadLetter.Caption() = New_Caption
PropertyChanged "Caption"
End Property
Private Sub LoadLetter_Click()
RaiseEvent Click
End Sub