By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,594 Members | 2,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,594 IT Pros & Developers. It's quick & easy.

Get the parent form of an activex control

P: 17
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(ByVal vNewValue As Variant)
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.
Nov 23 '07 #1
Share this Question
Share on Google+
1 Reply

P: 112

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

Expand|Select|Wrap|Line Numbers
  1.  Option Explicit 
  2. Private ShowState As Boolean
  3. Private ParentObject As Object
  5. Public Property Let HideForm(ByVal Hide As Boolean)
  6. ShowState=Hide
  7. Set ParentObject = UserControl.Parent
  8. ParentObject.Visible = Hide
  9. End Property
because you use Windows API Functions you will need HWND Property Value, you can use
Expand|Select|Wrap|Line Numbers
  1. FormHwnd=UserControl.Parent.Hwnd
Kind Regards
Nov 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.