Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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.

Example

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
  }

Requirements

Header: afxwin.h

Show: