Skip to content

Commit 3da9925

Browse files
committed
tray icon accidental double click problem fixed
1 parent da5dba4 commit 3da9925

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

OpenHardwareMonitor/UI/NotifyIconAdv.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ private class NotifyIconWindowsImplementation : Component
388388
private bool _doubleClickDown;
389389
private bool _visible;
390390
private readonly MethodInfo _commandDispatch;
391+
private DateTime _lastClickTime = DateTime.MinValue;
392+
private readonly int _doubleClickThreshold = SystemInformation.DoubleClickTime;
391393

392394
public event EventHandler BalloonTipClicked;
393395
public event EventHandler BalloonTipClosed;
@@ -635,6 +637,21 @@ private void UpdateNotifyIcon(bool showNotifyIcon)
635637

636638
private void ProcessMouseDown(MouseButtons button, bool doubleClick)
637639
{
640+
doubleClick = false;
641+
if (button == MouseButtons.Left)
642+
{
643+
DateTime now = DateTime.Now;
644+
if ((now - _lastClickTime).TotalMilliseconds <= _doubleClickThreshold)
645+
{
646+
_lastClickTime = DateTime.MinValue;
647+
doubleClick = true; //real double-click
648+
}
649+
else
650+
{
651+
_lastClickTime = now;
652+
}
653+
}
654+
638655
if (doubleClick)
639656
{
640657
DoubleClick?.Invoke(this, new MouseEventArgs(button, 2, 0, 0, 0));

0 commit comments

Comments
 (0)