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