게임개발/팁

다른 프로그램창 Top으로 올리기

쑥갓 2006. 1. 24. 04:41

윈도우를 Top으로 올리는건

SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
로 하면 되긴하지만, 이건 같은 어플리케이션내의 윈도우만 가능하다.


다른 어플리케이션의 윈도우는 이렇게 한다.

void ForceSetTop(HWND hWnd)
{
DWORD fromId = GetCurrentThreadId();
DWORD toId = GetWindowThreadProcessId(GetForegroundWindow(), NULL);

AttachThreadInput(fromId, toId, TRUE);
SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
AttachThreadInput(fromId, toId, FALSE);
}