From ad32fc889f6e0b9f3054f7421f147ee297f99b63 Mon Sep 17 00:00:00 2001 From: NaBian <836904362@qq.com> Date: Sun, 28 Mar 2021 13:06:21 +0800 Subject: [PATCH] fixed #748 --- .../Controls/Other/NotifyIcon.cs | 51 +++++++++---------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs b/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs index 6f196d76..db976dfd 100644 --- a/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs +++ b/src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs @@ -578,37 +578,34 @@ namespace HandyControl.Controls private IntPtr Callback(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam) { - if (IsLoaded) + if (msg == _wmTaskbarCreated) { - if (msg == _wmTaskbarCreated) + if (_messageWindowHandle == hWnd && Visibility == Visibility.Visible) { - if (_messageWindowHandle == hWnd && Visibility == Visibility.Visible) - { - UpdateIcon(true); - } + UpdateIcon(true); } - else + } + else + { + switch (lparam.ToInt64()) { - switch (lparam.ToInt64()) - { - case InteropValues.WM_LBUTTONDBLCLK: - WmMouseDown(MouseButton.Left, 2); - break; - case InteropValues.WM_LBUTTONUP: - WmMouseUp(MouseButton.Left); - break; - case InteropValues.WM_RBUTTONUP: - ShowContextMenu(); - WmMouseUp(MouseButton.Right); - break; - case InteropValues.WM_MOUSEMOVE: - if (!_dispatcherTimerPos.IsEnabled) - { - _dispatcherTimerPos.Interval = TimeSpan.FromMilliseconds(200); - _dispatcherTimerPos.Start(); - } - break; - } + case InteropValues.WM_LBUTTONDBLCLK: + WmMouseDown(MouseButton.Left, 2); + break; + case InteropValues.WM_LBUTTONUP: + WmMouseUp(MouseButton.Left); + break; + case InteropValues.WM_RBUTTONUP: + ShowContextMenu(); + WmMouseUp(MouseButton.Right); + break; + case InteropValues.WM_MOUSEMOVE: + if (!_dispatcherTimerPos.IsEnabled) + { + _dispatcherTimerPos.Interval = TimeSpan.FromMilliseconds(200); + _dispatcherTimerPos.Start(); + } + break; } }