HOWTO: Retrieve the Actual Parent Window of an ActiveX ControlLast reviewed: February 17, 1998Article ID: Q150204 |
The information in this article applies to:
SUMMARYAn ActiveX control is created as a child of the window of the container most closely associated with the site object. This article describes how to obtain the Parent window of an ActiveX control, and why calling GetParent or CWnd::GetParent for an ActiveX control may not return its actual Parent window.
MORE INFORMATIONAn ActiveX control typically gains access to the following container windows:
When the MFC framework creates an ActiveX control's window, it retrieves the window associated with the container's site object by calling IOleInPlaceSite::GetWindow. The returned window is made the parent of the ActiveX control, except in the following two cases, where the framework creates a reflector window that reflects the notification messages:
NOTE: If IOleObject::DoVerb with OLEIVERB_OPEN is invoked on an ActiveX control, and if in-place activation is not possible, an outer frame window is created and becomes the parent of the ActiveX control.
Sample Code
// The following code should return the // actual parent window of the ActiveX control. HWND CMyOleControl::GetActualParent() { HWND hwndParent = 0; // Get the window associated with the in-place site object, // which is connected to this ActiveX control. if (m_pInPlaceSite != NULL) m_pInPlaceSite->GetWindow(&hwndParent); return hwndParent; // Return the in-place site window handle. } REFERENCES
|
Additional query words: ocx control
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |