跨线程激活窗体

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);
}

你可能感兴趣的:(跨线程激活窗体)