[RESOLVED] Problem with LoadPicture in an ActiveX Control
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: [RESOLVED] Problem with LoadPicture in an ActiveX Control

  1. #1
    Join Date
    Mar 2009
    Posts
    19

    [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.

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,725

    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.

  3. #3
    Join Date
    Mar 2009
    Posts
    19

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center