跨线程激活窗体

来源:互联网 发布:无网络单机游戏下载 编辑:程序博客网 时间:2024/06/13 05:16

VOID PureSetForegroundWindow(HWND hWnd)
{
 ::AttachThreadInput(::GetCurrentThreadId(), ::GetWindowThreadProcessId(::GetForegroundWindow(), NULL), TRUE);
 ::ShowWindow(hWnd, SW_SHOWNORMAL);
 ::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
 ::SetWindowPos(hWnd, HWND_NOTOPMOST,0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
 ::SetForegroundWindow(hWnd);
 ::AttachThreadInput(::GetCurrentThreadId(),::GetWindowThreadProcessId(::GetForegroundWindow(), NULL), FALSE);
}