简体   繁体   中英

VB6 ActiveX Image.picture property

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM