From 92a7f778519b4a9ab9d977d6b2a657d214745ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20M=C3=B6ller?= Date: Tue, 7 Sep 2010 18:51:42 +0000 Subject: [PATCH] Fixed the GadgetWindow AlwaysOnTop option (could be lost by tracking "Show Desktop" events even when AlwaysOnTop = true). --- GUI/GadgetWindow.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/GUI/GadgetWindow.cs b/GUI/GadgetWindow.cs index 677379c..dc41c80 100644 --- a/GUI/GadgetWindow.cs +++ b/GUI/GadgetWindow.cs @@ -226,10 +226,13 @@ namespace OpenHardwareMonitor.GUI { NativeMethods.SetWindowPos(Handle, IntPtr.Zero, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | (value ? SWP_SHOWWINDOW : SWP_HIDEWINDOW)); - if (value) - ShowDesktop.Instance.ShowDesktopChanged += ShowDesktopChanged; - else - ShowDesktop.Instance.ShowDesktopChanged -= ShowDesktopChanged; + if (value) { + if (!alwaysOnTop) + ShowDesktop.Instance.ShowDesktopChanged += ShowDesktopChanged; + } else { + if (!alwaysOnTop) + ShowDesktop.Instance.ShowDesktopChanged -= ShowDesktopChanged; + } } } } @@ -252,11 +255,13 @@ namespace OpenHardwareMonitor.GUI { if (value != alwaysOnTop) { alwaysOnTop = value; if (alwaysOnTop) { - ShowDesktop.Instance.ShowDesktopChanged -= ShowDesktopChanged; + if (visible) + ShowDesktop.Instance.ShowDesktopChanged -= ShowDesktopChanged; MoveToTopMost(Handle); } else { MoveToBottom(Handle); - ShowDesktop.Instance.ShowDesktopChanged += ShowDesktopChanged; + if (visible) + ShowDesktop.Instance.ShowDesktopChanged += ShowDesktopChanged; } } }