如题
FindWindow(null,Text("A"))找不到A程序的窗口句柄
------解决方案--------------------
第二个参数是程序的窗口标题
- C/C++ code
CWnd::FindWindow This method retrieves the top-level CWnd whose window class is specified by lpszClassName and whose window name, or title, is specified by lpszWindowName. This method does not search child windows. static CWnd* PASCAL FindWindow( LPCTSTR lpszClassName, LPCTSTR lpszWindowName ); Parameters lpszClassName Points to a null-terminated string that specifies the window class name, a WNDCLASS structure. If the lpClassName parameter is NULL, then all class names result as a successful match. lpszWindowName Points to a null-terminated string that specifies the window name, the window title. If the lpWindowName parameter is NULL, then all window names result as a successful match. Return Value Identifies the window that has the specified class name and window name. It is NULL if no such window is found. The CWnd* may be temporary and should not be stored for later use. Example // Activate an application with a window with a specific class name. 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; } }