CWnd::Attach 

BOOL Attach( HWND hWndNew );

Return Value

Nonzero if successful; otherwise 0.

Parameters

hWndNew

Specifies a handle to a Windows window.

Remarks

Attaches a Windows window to a CWnd object.

Example

// Using Attach and Detach to map to the MDI client window
class CMainFrame : public CMDIFrameWnd
{
...
public:
   CWnd  m_wndMDIClient;
}

CMainFrame::~CMainFrame()
{
   // detach MDI client window
   m_wndMDIClient.Detach();
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
      return -1;

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

CWnd OverviewClass MembersHierarchy Chart

See Also   CWnd::Detach, CWnd::m_hWnd, CWnd::SubclassWindow