Get the parent form of an activex control

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sudhanshu
    New Member
    • Sep 2006
    • 17

    Get the parent form of an activex control

    hi
    I am new to creating ActiveX controls.
    I am trying to create a control to minimize a form to the system tray
    using windows API.
    For this I need a reference to the form, my control is placed in.
    How can i do this?
    I tried exposing a property "ParentFrm" of type Form.


    Public Property Let ParentForm(ByVa l vNewValue As Variant)
    ParentFrm=vNewV alue
    End Property


    This gives an error: Invalid use of property.

    I tried replacing variant by Form but this results in a compilation
    error: Private object modules can not be used in public object modules
    as parameter....


    Please help.
  • AHMEDYO
    New Member
    • Nov 2007
    • 112

    #2
    HI..

    UserControl Allready have Object refrence to Parent Object, you can use Parent object from ActiveX Control Class, For Example

    [CODE=vb] Option Explicit
    Private ShowState As Boolean
    Private ParentObject As Object

    Public Property Let HideForm(ByVal Hide As Boolean)
    ShowState=Hide
    Set ParentObject = UserControl.Par ent
    ParentObject.Vi sible = Hide
    End Property
    [/CODE]

    because you use Windows API Functions you will need HWND Property Value, you can use
    [CODE=vb]
    FormHwnd=UserCo ntrol.Parent.Hw nd
    [/CODE]

    Kind Regards

    Comment

    Working...