⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subject_17892.htm

📁 一些关于vc的问答
💻 HTM
字号:
<p>
序号:17892 发表者:zl 发表日期:2002-10-16 13:30:54
<br>主题:帮帮忙..............!
<br>内容:在任务管理器中如何切换到选定的任务!<BR>使用什么 API 函数呢?<BR>请您赐教!尽量详细!
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:紫瑗 回复日期:2002-10-16 14:14:32
<br>内容:我想你想是把另外一个进程的窗口放到最前面是吧?当然使用进程也可以,但是以下这种方法更为通用一点。<BR>你可以通过FindWindow()来做。<BR><BR>const&nbsp;&nbsp;&nbsp;&nbsp;char*&nbsp;&nbsp;&nbsp;&nbsp;lpszClassName&nbsp;&nbsp;&nbsp;&nbsp;="XXX Window Class 2";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>HWND&nbsp;&nbsp;&nbsp;&nbsp;hWnd&nbsp;&nbsp;&nbsp;&nbsp;=::FindWindowEx(NULL, NULL, lpszClassName, NULL);<BR>if(NULL != hWnd &&&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::IsWindow(hParentWnd))<BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::ShowWindow(hWnd, SW_RESTORE);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::BringWindowToTop(hWnd);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;RECT&nbsp;&nbsp;&nbsp;&nbsp;rect;<BR>&nbsp;&nbsp;&nbsp;&nbsp;memset(&rect, 0, sizeof(RECT));<BR>&nbsp;&nbsp;&nbsp;&nbsp;::GetWindowRect(hWnd, &rect);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::ModifyStyleEx(hWnd, 0, WS_EX_TOPMOST, 0);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::SetWindowPos(hWnd, HWND_TOPMOST, rect.left, rect.top,&nbsp;&nbsp;&nbsp;&nbsp;rect.right - rect.left, rect.bottom - rect.top, SWP_SHOWWINDOW);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::ModifyStyleEx(hWnd, WS_EX_TOPMOST, 0, 0);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;::SetWindowPos(hWnd, HWND_NOTOPMOST, rect.left, rect.top,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rect.right - rect.left, rect.bottom - rect.top, SWP_SHOWWINDOW);<BR>}<BR>附上FindWindowEx说明<BR>FindWindowEx<BR>The FindWindowEx function retrieves a handle to a window whose class name and window name match the specified strings. The function searches child windows, beginning with the one following the specified child window. This function does not perform a case-sensitive search. <BR><BR>HWND FindWindowEx(<BR>&nbsp;&nbsp;HWND hwndParent,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// handle to parent window<BR>&nbsp;&nbsp;HWND hwndChildAfter,&nbsp;&nbsp;// handle to child window<BR>&nbsp;&nbsp;LPCTSTR lpszClass,&nbsp;&nbsp;&nbsp;&nbsp;// class name<BR>&nbsp;&nbsp;LPCTSTR lpszWindow&nbsp;&nbsp;&nbsp;&nbsp;// window name<BR>);<BR>Parameters<BR>hwndParent <BR>[in] Handle to the parent window whose child windows are to be searched. <BR>If hwndParent is NULL, the function uses the desktop window as the parent window. The function searches among windows that are child windows of the desktop. <BR><BR>Windows 2000: If hwndParent is HWND_MESSAGE, the function searches all message-only windows. <BR><BR>hwndChildAfter <BR>[in] Handle to a child window. The search begins with the next child window in the Z order. The child window must be a direct child window of hwndParent, not just a descendant window. <BR>If hwndChildAfter is NULL, the search begins with the first child window of hwndParent. <BR><BR>Note that if both hwndParent and hwndChildAfter are NULL, the function searches all top-level and message-only windows. <BR><BR>lpszClass <BR>[in] Pointer to a null-terminated string that specifies the class name or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be placed in the low-order word of lpszClass; the high-order word must be zero. <BR>If lpszClass is a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, or any of the predefined control-class names. <BR><BR>lpszWindow <BR>[in] Pointer to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match. <BR>Return Values<BR>If the function succeeds, the return value is a handle to the window that has the specified class and window names.<BR><BR>If the function fails, the return value is NULL. To get extended error information, call GetLastError. <BR><BR>Remarks<BR>If the lpWindowName parameter is not NULL, FindWindowEx calls the GetWindowText function to retrieve the window name for comparison. For a description of a potential problem that can arise, see the Remarks for GetWindowText. <BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:zl 回复日期:2002-10-16 15:19:53
<br>内容:谢谢大姐
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:zl 回复日期:2002-10-16 15:23:14
<br>内容:可是如何得到应用程序的 lpszClassName呢????
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:紫瑗 回复日期:2002-10-16 15:29:11
<br>内容:不是应用程序,是应用程序的窗口,用窗口名称或窗口的Class名称也是可以的。<BR>BTW:我是男的。
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:zl 回复日期:2002-10-16 15:30:24
<br>内容:SORRY,<BR>你的意思是枚举所有的程序窗口是吗?
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -