BOOL COneT32App::FirstInstance() { CWnd *pWndPrev, *pWndChild; // Determine if a window with the class name exists... if (pWndPrev = CWnd::FindWindow(_T("MyNewClass"),NULL)) { // 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; } } FindWindow("类名","标题");
{
CWnd *pWndPrev, *pWndChild; // Determine if a window with the class name exists...
if (pWndPrev = CWnd::FindWindow(_T("MyNewClass"),NULL))
{
// 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;
}
}
FindWindow("类名","标题");