GUI/GadgetWindow.cs
changeset 180 d40f49d45614
parent 176 c16fd81b520a
child 183 3096735e99b2
     1.1 --- a/GUI/GadgetWindow.cs	Tue Sep 07 18:40:00 2010 +0000
     1.2 +++ b/GUI/GadgetWindow.cs	Tue Sep 07 18:51:42 2010 +0000
     1.3 @@ -226,10 +226,13 @@
     1.4            NativeMethods.SetWindowPos(Handle, IntPtr.Zero, 0, 0, 0, 0,
     1.5              SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER |
     1.6              (value ? SWP_SHOWWINDOW : SWP_HIDEWINDOW));
     1.7 -          if (value)
     1.8 -            ShowDesktop.Instance.ShowDesktopChanged += ShowDesktopChanged;
     1.9 -          else
    1.10 -            ShowDesktop.Instance.ShowDesktopChanged -= ShowDesktopChanged;         
    1.11 +          if (value) {
    1.12 +            if (!alwaysOnTop)
    1.13 +              ShowDesktop.Instance.ShowDesktopChanged += ShowDesktopChanged;
    1.14 +          } else {
    1.15 +            if (!alwaysOnTop)
    1.16 +              ShowDesktop.Instance.ShowDesktopChanged -= ShowDesktopChanged;
    1.17 +          }
    1.18          }
    1.19        }
    1.20      }
    1.21 @@ -252,11 +255,13 @@
    1.22          if (value != alwaysOnTop) {
    1.23            alwaysOnTop = value;
    1.24            if (alwaysOnTop) {
    1.25 -            ShowDesktop.Instance.ShowDesktopChanged -= ShowDesktopChanged;
    1.26 +            if (visible)
    1.27 +              ShowDesktop.Instance.ShowDesktopChanged -= ShowDesktopChanged;
    1.28              MoveToTopMost(Handle);            
    1.29            } else {
    1.30              MoveToBottom(Handle);
    1.31 -            ShowDesktop.Instance.ShowDesktopChanged += ShowDesktopChanged;
    1.32 +            if (visible)
    1.33 +              ShowDesktop.Instance.ShowDesktopChanged += ShowDesktopChanged;
    1.34            }
    1.35          }
    1.36        }