diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2019-10-06 14:40:40 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2019-10-06 14:40:40 +0900 |
commit | cc97135f9bc5a28c2bcd782bbb024517e3af974a (patch) | |
tree | 35808fb37b2f67e94aeff02a37249bae52272f08 | |
parent | bb7f4c331aab6539067e4f932718e70f8f0ac004 (diff) | |
download | wf-clock-cc97135f9bc5a28c2bcd782bbb024517e3af974a.tar.gz |
call SetWindowPos() with HWND_NOTOPMOST explicitly
It seems that calling SetWindowPost() with the currently-active window
handle does not really reset the topmost flag.
-rw-r--r-- | WarframeClock/OverlayWindowBase.cs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/WarframeClock/OverlayWindowBase.cs b/WarframeClock/OverlayWindowBase.cs index 5859e81..0479d30 100644 --- a/WarframeClock/OverlayWindowBase.cs +++ b/WarframeClock/OverlayWindowBase.cs @@ -46,6 +46,14 @@ namespace WarframeClock if (currentActiveWindow != IntPtr.Zero && (!IsVisible || currentActiveWindow == _targetWindowHandle != _xTopmost)) { + const uint flags = + 0x0001 /* SWP_NOSIZE */ | + 0x0002 /* SWP_NOMOVE */ | + 0x0008 /* SWP_NOREDRAW */ | + 0x0010 /* SWP_NOACTIVATE */ | + 0x0200 /* SWP_NOOWNERZORDER */ | + 0x0400 /* SWP_NOSENDCHANGING */; + // Setting Topmost to false brings the overlay to just // behind the other top-most window -- above the foreground // window. This is not what we want to do here. @@ -54,21 +62,15 @@ namespace WarframeClock { Trace.WriteLine("OverlayWindowBase: Overlay is now top-most"); _xTopmost = true; + Native.SetWindowPos(_windowHandle, new IntPtr(-1), 0, 0, 0, 0, flags); } else { Trace.WriteLine($"OverlayWindowBase: Overlay is now non-top-most, behind {currentActiveWindow}"); _xTopmost = false; + Native.SetWindowPos(_windowHandle, currentActiveWindow, 0, 0, 0, 0, flags); + Native.SetWindowPos(_windowHandle, new IntPtr(-2), 0, 0, 0, 0, flags); } - - const uint flags = - 0x0001 /* SWP_NOSIZE */ | - 0x0002 /* SWP_NOMOVE */ | - 0x0008 /* SWP_NOREDRAW */ | - 0x0010 /* SWP_NOACTIVATE */ | - 0x0200 /* SWP_NOOWNERZORDER */ | - 0x0400 /* SWP_NOSENDCHANGING */; - Native.SetWindowPos(_windowHandle, _xTopmost ? (IntPtr)(-1) : currentActiveWindow, 0, 0, 0, 0, flags); } // Adjust window position |