title: How to keep my topmost window on top?
body: <p>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. </p>
  
  <p>I am using C++ on Win XP, so when the window is created (CreateWindowEx(WS_EX_TOPMOST | WS_EX_TRANSPARENT ...) everything works fine. </p>
  
  <p>Unfortunately, if a user moves another topmost window, for example the taskbar over my window, I don't get mouse movements. </p>
  
  <p>I tried to solve this similarly to approaches suggested in:
  <a href="http://support.microsoft.com/kb/108315" rel="noreferrer">How To Keep an MDI Window Always on Top</a></p>
  
  <p>I tried to check for Z-order of my topmost window in WM_WINDOWPOSCHANGED first with</p>
  
  <pre><code>case WM_WINDOWPOSCHANGED :
      WINDOWPOS* pWP = (WINDOWPOS*)lParam;
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>case WM_WINDOWPOSCHANGED :
      HWND topWndHndl = GetNextWindow(myHandle, GW_HWNDPREV)
      GetWindowText(topWndHndl, pszMem, cTxtLen + 1);
  </code></pre>
  
  <p>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. </p>
  
  <p>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>
  
  <p>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.)</p>
  
  <p>Thank you on your time and suggestions!</p>