Share via


CWnd::FindWindow

ウィンドウ クラスが lpszClassName によって割り当てられ、ウィンドウの名前、またはタイトルが lpszWindowNameによって、指定したトップレベル CWnd を返します。

static CWnd* PASCAL FindWindow( 
   LPCTSTR lpszClassName, 
   LPCTSTR lpszWindowName  
);

パラメーター

  • lpszClassName
    ウィンドウ クラスの名前 ( WNDCLASS の構造) を指定する NULL で終わる文字列へのポインター。 lpClassName が nullの場合、すべてのクラス名に一致します。

  • lpszWindowName
    ウィンドウの名前 (ウィンドウのタイトル) を指定する NULL で終わる文字列へのポインター。 lpWindowName が null場合、すべてのウィンドウが一致を示します。

戻り値

指定したクラス名、ウィンドウ名を持つウィンドウを識別します。 、などのペインが存在 null です。

CWnd*一時的には存在、後で使用できるように保存しないでください。

解説

この関数は、子ウィンドウを検索しません。

使用例

// activate an application with a window with a specific class name
BOOL CMyApp::FirstInstance()
{
   CWnd *pWndPrev, *pWndChild;

   // Determine if a window with the class name exists...
   pWndPrev = CWnd::FindWindow(_T("MyNewClass"), NULL);
   if (NULL != pWndPrev)
   {
      // If so, does it have any popups?
      pWndChild = pWndPrev->GetLastActivePopup();

      // If iconic, restore the main window 
      if (pWndPrev->IsIconic())
         pWndPrev->ShowWindow(SW_RESTORE);

      // Bring the main window or its popup to the foreground
      pWndChild->SetForegroundWindow();

      // and you are done activating the other application 
      return FALSE;
   }

   return TRUE;
}

必要条件

ヘッダー: afxwin.h

参照

関連項目

CWnd クラス

階層図

FindWindow