且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

避免应用程序激活和在单击按钮上时的重点 - Windows API或Qt

更新时间:2023-02-13 14:30:58

It is possible to make a window unactivable and unfocusable when clicking on it by using Windows flags (#include <qt_windows.h>). 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);