mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-02-16 11:08:30 -05:00
FIX Fixed potential event propagation before event listeners where registered.
This commit is contained in:
@@ -25,7 +25,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
||||||
{
|
{
|
||||||
@@ -119,7 +118,6 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
|||||||
public WindowMessageSink(NotifyIconVersion version)
|
public WindowMessageSink(NotifyIconVersion version)
|
||||||
{
|
{
|
||||||
Version = version;
|
Version = version;
|
||||||
CreateMessageWindow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -127,6 +125,10 @@ 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
|
||||||
@@ -154,7 +156,7 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
|||||||
private void CreateMessageWindow()
|
private void CreateMessageWindow()
|
||||||
{
|
{
|
||||||
//generate a unique ID for the window
|
//generate a unique ID for the window
|
||||||
WindowId = "WPFTaskbarIcon_" + DateTime.Now.Ticks;
|
WindowId = "WPFTaskbarIcon_" + Guid.NewGuid();
|
||||||
|
|
||||||
//register window message handler
|
//register window message handler
|
||||||
messageHandler = OnWindowMessageReceived;
|
messageHandler = OnWindowMessageReceived;
|
||||||
|
|||||||
@@ -142,6 +142,9 @@ 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);
|
||||||
|
|||||||
Reference in New Issue
Block a user