I will first explain why I need it, because I anticipate that the first response will be "Why do you need it?". I want to detect when the mouse cursor is on an edge of the screen and I don't want to use hooks. Hence, I created one pixel wide TOPMOST invisible window.
I am using C++ on Win XP, so when the window is created (CreateWindowEx(WS_EX_TOPMOST | WS_EX_TRANSPARENT ...) everything works fine.
Unfortunately, if a user moves another topmost window, for example the taskbar over my window, I don't get mouse movements.
I tried to solve this similarly to approaches suggested in: How To Keep an MDI Window Always on Top
I tried to check for Z-order of my topmost window in WM_WINDOWPOSCHANGED first with
case WM_WINDOWPOSCHANGED :
WINDOWPOS* pWP = (WINDOWPOS*)lParam;
yet pWP->hwnd points to my window and pWP->hwndInsertAfter is 0, which should mean that my window is on the top of the Z, even though it is covered with the taskbar. Then I tried:
case WM_WINDOWPOSCHANGED :
HWND topWndHndl = GetNextWindow(myHandle, GW_HWNDPREV)
GetWindowText(topWndHndl, pszMem, cTxtLen + 1);
and I'll always get that the "Default IME" window is on top of my window. Even if try to bring my window to the top with SetWindowPos() or BringWindowToTop (), "Default IME" stays on the top. I don't know what is "Default IME" and how to detect if the taskbar is on top of my window.
So my question is: How to detect that my topmost window is not the top topmost window anymore and how to keep it on the top?
P.S. I know that a "brute force" approach of periodically bringing my window to the top works, yet is ugly and could have some unwanted inference with the notification window for example. (Bringing my window to the top will hide the notification window.)
Thank you on your time and suggestions!
There are also keyboard shortcuts available here. Press “Ctrl +F11” to pin a window on top and press “Ctrl + F12” to disable it. You can customize the shortcuts by right-clicking on the app and navigating to “Options -> Hotkeys”.
Use the “Ctrl + Space” shortcut (or the shortcut you created) to pin a window on top.
Now you can press Ctrl + Space keyboard shortcut to set any active window always on top. Then when you use Chrome browser, you can press Ctrl + Space to make Chrome always on top, and press Ctrl + Space again to disable Chrome always on top.
Select Start , scroll to the app you want to pin, then press and hold (or right-click) the app. Select More > Pin to taskbar. If the app is already open on the desktop, press and hold (or right click) the app's taskbar icon, and then select Pin to taskbar.
TopMost, is always a tricky thing. There is no way to override another window that specifies itself as TopMost.
Raymond Chen has a good article on this.
Also a duplicate of this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With