Avoid application activation and focus in when clicking buttons on it - Windows API or Qt

后端 未结 2 1643
遇见更好的自我
遇见更好的自我 2021-01-18 11:58

Situation: A border-less QDialog stays successfully on top of other applications.

The problem is when clicking on this always-on-top application window, the followin

2条回答
  •  后悔当初
    2021-01-18 12:54

    It is possible to make a window unactivable and unfocusable when clicking on it by using Windows flags (#include ). The following has to be used after the window is created and shown:

    HWND winHandle = (HWND)winId();
    ShowWindow(winHandle, SW_HIDE);
    SetWindowLong(winHandle, GWL_EXSTYLE, GetWindowLong(winHandle, GWL_EXSTYLE)
        | WS_EX_NOACTIVATE | WS_EX_APPWINDOW);
    ShowWindow(winHandle, SW_SHOW);
    

提交回复
热议问题