Files
nekoray/sys/windows/guihelper.cpp
2022-11-27 18:24:21 +09:00

16 lines
433 B
C++

#include "guihelper.h"
#include <QWidget>
#include <windows.h>
void Windows_QWidget_SetForegroundWindow(QWidget* w) {
HWND hForgroundWnd = GetForegroundWindow();
DWORD dwForeID = ::GetWindowThreadProcessId(hForgroundWnd, NULL);
DWORD dwCurID = ::GetCurrentThreadId();
::AttachThreadInput(dwCurID, dwForeID, TRUE);
::SetForegroundWindow((HWND) w->winId());
::AttachThreadInput(dwCurID, dwForeID, FALSE);
}