mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-02-16 11:08:30 -05:00
FIX Delayed message sink listener causing interop issues.
This commit is contained in:
@@ -118,6 +118,7 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
|||||||
public WindowMessageSink(NotifyIconVersion version)
|
public WindowMessageSink(NotifyIconVersion version)
|
||||||
{
|
{
|
||||||
Version = version;
|
Version = version;
|
||||||
|
CreateMessageWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -125,11 +126,6 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void Listen()
|
|
||||||
{
|
|
||||||
CreateMessageWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a dummy instance that provides an empty
|
/// Creates a dummy instance that provides an empty
|
||||||
/// pointer rather than a real window handler.<br/>
|
/// pointer rather than a real window handler.<br/>
|
||||||
@@ -209,7 +205,8 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
|||||||
if (messageId == taskbarRestartMessageId)
|
if (messageId == taskbarRestartMessageId)
|
||||||
{
|
{
|
||||||
//recreate the icon if the taskbar was restarted (e.g. due to Win Explorer shutdown)
|
//recreate the icon if the taskbar was restarted (e.g. due to Win Explorer shutdown)
|
||||||
TaskbarCreated();
|
var listener = TaskbarCreated;
|
||||||
|
if(listener != null) listener();
|
||||||
}
|
}
|
||||||
|
|
||||||
//forward message
|
//forward message
|
||||||
@@ -280,12 +277,14 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x402:
|
case 0x402:
|
||||||
BalloonToolTipChanged(true);
|
var listener = BalloonToolTipChanged;
|
||||||
|
if (listener != null) listener(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x403:
|
case 0x403:
|
||||||
case 0x404:
|
case 0x404:
|
||||||
BalloonToolTipChanged(false);
|
listener = BalloonToolTipChanged;
|
||||||
|
if (listener != null) listener(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x405:
|
case 0x405:
|
||||||
@@ -293,11 +292,13 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x406:
|
case 0x406:
|
||||||
ChangeToolTipStateRequest(true);
|
listener = ChangeToolTipStateRequest;
|
||||||
|
if (listener != null) listener(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x407:
|
case 0x407:
|
||||||
ChangeToolTipStateRequest(false);
|
listener = ChangeToolTipStateRequest;
|
||||||
|
if (listener != null) listener(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The time we should wait for a double click.
|
/// The time we should wait for a double click.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int doubleClickWaitTime
|
private int DoubleClickWaitTime
|
||||||
{
|
{
|
||||||
get { return NoLeftClickDelay ? 0 : WinApi.GetDoubleClickTime(); }
|
get { return NoLeftClickDelay ? 0 : WinApi.GetDoubleClickTime(); }
|
||||||
}
|
}
|
||||||
@@ -142,9 +142,6 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
messageSink.ChangeToolTipStateRequest += OnToolTipChange;
|
messageSink.ChangeToolTipStateRequest += OnToolTipChange;
|
||||||
messageSink.BalloonToolTipChanged += OnBalloonToolTipChanged;
|
messageSink.BalloonToolTipChanged += OnBalloonToolTipChanged;
|
||||||
|
|
||||||
//start listening once we registered to events
|
|
||||||
if(!Util.IsDesignMode) messageSink.Listen();
|
|
||||||
|
|
||||||
//init single click / balloon timers
|
//init single click / balloon timers
|
||||||
singleClickTimer = new Timer(DoSingleClickAction);
|
singleClickTimer = new Timer(DoSingleClickAction);
|
||||||
balloonCloseTimer = new Timer(CloseBalloonCallback);
|
balloonCloseTimer = new Timer(CloseBalloonCallback);
|
||||||
@@ -428,7 +425,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
|
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
|
||||||
ShowTrayPopup(cursorPosition);
|
ShowTrayPopup(cursorPosition);
|
||||||
};
|
};
|
||||||
singleClickTimer.Change(doubleClickWaitTime, Timeout.Infinite);
|
singleClickTimer.Change(DoubleClickWaitTime, Timeout.Infinite);
|
||||||
isLeftClickCommandInvoked = true;
|
isLeftClickCommandInvoked = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -450,7 +447,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
|
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
|
||||||
ShowContextMenu(cursorPosition);
|
ShowContextMenu(cursorPosition);
|
||||||
};
|
};
|
||||||
singleClickTimer.Change(doubleClickWaitTime, Timeout.Infinite);
|
singleClickTimer.Change(DoubleClickWaitTime, Timeout.Infinite);
|
||||||
isLeftClickCommandInvoked = true;
|
isLeftClickCommandInvoked = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -469,7 +466,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
{
|
{
|
||||||
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
|
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
|
||||||
};
|
};
|
||||||
singleClickTimer.Change(doubleClickWaitTime, Timeout.Infinite);
|
singleClickTimer.Change(DoubleClickWaitTime, Timeout.Infinite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user