INFO: Retrieving the CMDIChildWnd Parent Window (101184)



The information in this article applies to:

  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++ for Windows, 16-bit edition 1.0
    • Microsoft Visual C++ for Windows, 16-bit edition 1.5
    • Microsoft Visual C++ for Windows, 16-bit edition 1.51
    • Microsoft Visual C++ for Windows, 16-bit edition 1.52
    • Microsoft Visual C++, 32-bit Editions 1.0
    • Microsoft Visual C++, 32-bit Editions 2.0
    • Microsoft Visual C++, 32-bit Editions 2.1
    • Microsoft Visual C++, 32-bit Editions 4.0

This article was previously published under Q101184

SUMMARY

When creating a CMDIChildWnd, the parent of the multiple document interface (MDI) window is a "MDICLIENT" control. The handle to the parent frame window can be retrieved in the following way:
   hwnd =::GetParent(lpcreatestruct.hwndParent);
				
Alternatively, use the following
   CMDIFrameWnd* pFrame = (CMDIFrameWnd*)GetParentFrame();
				
to acquire a pointer to the parent MDI frame window object.

NOTE: GetParentFrame is declared to return a pointer to a CFrameWnd object, and therefore it is necessary to typecast the result to a CMDIFrameWnd object.

Modification Type:MajorLast Reviewed:12/2/2003
Keywords:kbDocView kbinfo kbMDI KbUIDesign KB101184