Share via


CWnd::Attach

CWnd のオブジェクトに Windows のウィンドウをアタッチします。

BOOL Attach(
   HWND hWndNew 
);

パラメーター

  • hWndNew
    Windows のウィンドウを識別するハンドルを指定します。

戻り値

正常終了した場合は 0 以外を返します。それ以外の場合は 0 を返します。

使用例

この例では、MDI クライアント ウィンドウに割り当てるためにアタッチとデタッチを使用する方法を示します。

// 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
   }

必要条件

ヘッダー: afxwin.h

参照

関連項目

CWnd クラス

階層図

CWnd::Detach

CWnd::m_hWnd

CWnd::SubclassWindow