Reputation: 1686
I am trying to create an ActiveX OCX in VB6 with a picture property. The picture property sets and gets the picture property of an image in the control. I want the user to be able to select the image during design time.
Any ideas?
Thanks
Upvotes: 4
Views: 1568
Reputation: 78183
Just define a property of type IPictureDisp
.
Public Property Get Picture() As IPictureDisp
Set Picture = UserControl.Picture
End Property
Public Property Set Picture(ByVal p As IPictureDisp)
Set UserControl.Picture = p
PropertyChanged "Picture"
End Property
Don't forget to save to/read from the prop bag:
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
With PropBag
...
Set Me.Picture = .ReadProperty("Picture", Nothing)
...
End With
End Sub
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
With PropBag
...
.WriteProperty "Picture", Me.Picture, Nothing
...
End With
End Sub
Upvotes: 6