특정 윈도우를 화면 맨 앞으로 불러올 때 사용하는 함수가 뭔가요?
글쓴이: mydream / 작성시간: 화, 2015/09/08 - 6:09오후
다른 윈도우를 클릭해 선택한 상황에서 일정한 시간이 지나면 언급한 윈도우가 뜨도록 하고싶습니다. SetActiveWindow, SefFocus, SetForegroundWindow를 모두 사용해봤는데, 언급한 윈도우가 맨 앞으로 튀어나오질 않습니다. 어떤 함수를 어떻게 사용해야 원하는 효과를 얻을 수 있을까요? 그리고 상태를 다시 원위치로 시킬 때는 또 어떻게 해야 하고요? 반환되는 핸들 있으면 할 수 있을것 같은데요.
Forums:
SetForegroundWindow 함수를 쓰시면 됩니다.
SetForegroundWindow 함수를 쓰시면 됩니다.
다만 이 함수는 제한 사항이 있습니다. MSDN에서 SetForegroundWindow 함수에 대한 설명을 보시면,
"An application cannot force a window to the foreground while the user is working with another window. Instead, Windows flashes the taskbar button of the window to notify the user."
라 나와 있습니다.
이 제한 사항에 대한 해법으로는 AttachThreadInput 함수를 이용해서 내 스레드의 입력 큐를 해당 창의 스레드 입력 큐에 붙이는 방법이 있습니다.
대상 창의 스레드 ID 값은 GetWindowThreadProcessId 함수를 이용해서 얻어오면 되고요.
대략 다음과 같이 하시면 됩니다.
AttachThreadInput(dwThreadIdMe = GetCurrentThreadId(), dwThreadId = GetWindowThreadProcessId(hWnd, NULL), TRUE);
SetForegroundWindow(hWnd);
AttachThreadInput(dwThreadIdMe, dwThreadId, FALSE);
아 코드에 오류가 있네요. 수정합니다.
AttachThreadInput(dwThreadIdMe = GetCurrentThreadId(), dwThreadId = GetWindowThreadProcessId(GetForegroundWindow(), NULL), TRUE);
SetForegroundWindow(hWnd);
AttachThreadInput(dwThreadIdMe, dwThreadId, FALSE);
SetWindowPos()
SetWindowPos()
댓글 달기