CWnd::Attach

Attaches a Windows window to a CWnd object.

BOOL Attach( 
   HWND hWndNew  
);

hWndNew

Specifies a handle to a Windows window.

Nonzero if successful; otherwise 0.

This example shows how to use Attach and Detach to map to the MDI client window.

// Declare a CWnd member of CMainFrame 
public:
   CWnd m_wndMDIClient;
// detach MDI client window in CMainFrame destructor
m_wndMDIClient.Detach();
   // In CMainFrame::OnCreate, attach MDI client window 

	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

   // attach MDI client window 
   if (m_wndMDIClient.Attach(m_hWndMDIClient) == 0)
   {
      TRACE(_T("Failed to attach MDIClient.\n"));
      return -1;      // fail to create
   }

Header: afxwin.h

Community Additions

ADD
Show: