能介绍一下EnumThreadWindows的用法吗?最好有例子!!!

ygwaatas 2002-08-15 09:54:34
能介绍一下EnumThreadWindows的用法吗?最好有例子!!!
...全文
453 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
huzhangyou 2002-08-15
  • 打赏
  • 举报
回复



static const TCHAR szAfxOldWndProc[] = _T("AfxOldWndProc");

BOOL CALLBACK EnumProc( HWND hWnd, LPARAM lParam)
{
WNDPROC oldWndProc = (WNDPROC)::GetProp(hWnd, szAfxOldWndProc);
if (oldWndProc!=NULL)
{
SetWindowLong(hWnd, GWL_WNDPROC, (DWORD)oldWndProc);
RemoveProp(hWnd, szAfxOldWndProc);
}

return TRUE;
}

void CMainFrame::OnEndSession(BOOL bEnding)
{DWORD dwProcessId;

DWORD dwThreadId= GetWindowThreadProcessId(m_hWnd,&dwProcessId);
EnumThreadWindows(dwThreadId, EnumProc,(LPARAM) dwThreadId);
}



huzhangyou 2002-08-15
  • 打赏
  • 举报
回复
BOOL CALLBACK EnumProc(
HWND hwnd,
LPARAM lParam)
{
// Send a WM_CLOSE to destroy the window, because DestroyWindow
// does not work across threads.

SendMessage(hwnd, WM_CLOSE, 0, 0);
return TRUE;
}

BOOL ConsoleCtrlHandler(
DWORD dwCtrlType)
{
if (dwCtrlType == CTRL_LOGOFF_EVENT && dwGuiThreadId != 0)
{
SetThreadDesktop(GetThreadDesktop(dwGuiThreadId));
EnumThreadWindows(dwGuiThreadId, EnumProc, 0);
}
return FALSE;
}



这个就可以
huzhangyou 2002-08-15
  • 打赏
  • 举报
回复
BOOL EnumThreadWindows(
DWORD dwThreadId, // thread identifier
WNDENUMPROC lpfn, // pointer to callback function
LPARAM lParam // application-defined value
);

Parameters
dwThreadId
Identifies the thread whose windows are to be enumerated.
lpfn
Pointer to an application-defined callback function. For more information, see EnumThreadWndProc.
lParam
Specifies an application-defined value to be passed to the callback function.
Return Values
If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, callGetLastError.


这是msdn的

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧