简体   繁体   中英

How do I set a Windows application to be always below other windows?

I would like to be able to set any window (for example Google Chrome) to be always below all other windows and prevent it to come to the top when activated. I found this on stackoverflow. What I am looking for is nearly the same, but for compiled applications. Using Ubuntu I could achieve this using wmctrl -i -r <window_handle> -b add,below but I found no corresponding possibility under Windows (in my case Windows 7 x64).

I could not find such a command line function but you could still do it from a compiled program.

First find Google Chrome's window handle: Source

The only way I know of is to enumerate all the top level windows with EnumWindows() and then find what process each belongs to GetWindowThreadProcessID(). This sounds indirect and inefficient, but it's not as bad as you might expect -- in a typical case, you might have a dozen top level windows to walk through...

Then use SetWindowPos with the flag HWND_BOTTOM for that HWND. The user might try to bring Chrome to the foreground which you could prevent by checking GetForegroundWindow and if necessary call SetWindowPos again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM