March 4th, 2009, 03:25 AM
[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)
Now when I try to use this property in a form at run time:
'WARNING! DO NOT REMOVE OR MODIFY THE FOLLOWING COMMENTED LINES!
Public Property Get Picture() As Picture
Attribute Picture.VB_Description = "Returns/sets a graphic to be displayed in a control."
Set Picture = Picture1.Picture
Public Property Set Picture(ByVal New_Picture As Picture)
Set Picture1.Picture = New_Picture
For Picture1, I get "Invalid use of property" compile error.
Picture1.Picture = LoadPicture("d:\xyz.jpg") 'Picture1 is my activeX control
Picture2.Picture = LoadPicture("d:\xyz.jpg") 'Picture2 is a VB picture Box
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.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!