[RESOLVED] Problem with LoadPicture in an ActiveX Control
Hi guys, a problem and I have no promising clue:
I have created an activeX control which has a PictureBox. I have exposed Picture property like this:
(Picture1 is the name of constituent PictureBox drawn on UserControl)
Code:
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
'MappingInfo=Picture1,Picture1,-1,Picture
Public Property Get Picture() As Picture
Attribute Picture.VB_Description = "Returns/sets a graphic to be displayed in a control."
Set Picture = Picture1.Picture
End Property
Public Property Set Picture(ByVal New_Picture As Picture)
Set Picture1.Picture = New_Picture
PropertyChanged "Picture"
End Property
Now when I try to use this property in a form at run time:
Code:
Picture1.Picture = LoadPicture("d:\xyz.jpg") 'Picture1 is my activeX control
Picture2.Picture = LoadPicture("d:\xyz.jpg") 'Picture2 is a VB picture Box
For Picture1, I get "Invalid use of property" compile error.
However, if I comment line1 and run, it runs normally for Picture2.
Then I tried changing data type Picture to StdPicture and IPictureDisp in Get and Let, but got same error.
I have confirmed that LoadPicture is indeed referring to VB.Loadpicture and not something else in my code.
Please not that I can set the picture alright at design time from properties windows. The error occurs only at run time. Also I haven't coded the property manually, it has been added by VB's ActiveX Interface Wizard.
My aim is to use LoadPicture normally for my activeX control as we use for a PictureBox. Alternative implementation of Get and Let for Picture property will also do. Only condition is that it should work as normal PictureBox.
I have exposed all the properties of PictureBox in my control, but so far only LoadPicture has given problem.
Thanks for your time.
Re: Problem with LoadPicture in an ActiveX Control
Maybe there is a naming conflict of your ActiveX control having the same name as the PictureBox inside your control.
Try to give another name as Picture1 to your internal PictureBox.
I'm not sure, but I had already naming issues when writing a UserControl. It may be worth a try.
Re: Problem with LoadPicture in an ActiveX Control
Hi WoF. Problem solved. :)
It was not a naming conflict issue though.
I had to expose the Picture property with:
Code:
Public Property Let Picture(thePic As stdPicture)
Set Me.Picture = thePic
End Property
Public Property Set Picture(thePic As stdPicture)
Set Picture1.Picture = thePic
End Property
Public Property Get Picture() as stdPicture
Set Picture = Picture1.Picture
End Property
Thanks for your time.