본문 바로가기
『 C 』Languege/winapi

winapi 최상위 윈도우로 설정하기

by Play IT 2019. 5. 27.
반응형

1.BringWindowToTop을 쓰기위해 아래를 사용해야한다.

if(::GetForegroundWindow() != this->m_hWnd){ 
    HWND h_active_wnd = ::GetForegroundWindow(); 
    if(h_active_wnd != NULL){ 
        DWORD thread_id = GetWindowThreadProcessId(h_active_wnd, NULL); 
        DWORD current_thread_id = GetCurrentThreadId(); 
        if(current_thread_id != thread_id){ 
            if(AttachThreadInput(current_thread_id, thread_id, TRUE)){ 
                BringWindowToTop(); 
                AttachThreadInput(current_thread_id, thread_id, FALSE); 
            } 
        } 
    } 
} 

 

 

2. 강제로 윈도우를 최상위로 설정한다.

SetWindowPos(m_pMainWnd->m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, 
                                          SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW); 

3. 최상위 윈도우를 삭제한다.

SetWindowPos(m_pMainWnd->m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, 
                                          SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW); 

반응형

댓글