refactor: NotifyIcon balloon tip event handling.
This commit is contained in:
1 parent
f5c5821a8c
commit
64da563916
2 files changed
+11
-12
No files matched your search
@@ -34,10 +34,6 @@ public class NotifyIcon : FrameworkElement, IDisposable
|
|||||||
|
|
||||||
private IconHandle _iconHandle;
|
private IconHandle _iconHandle;
|
||||||
|
|
||||||
private const int WmTrayMouseMessage = InteropValues.WM_USER + 1024;
|
|
||||||
|
|
||||||
private const int NIN_BALLOONUSERCLICK = InteropValues.WM_USER + 1025;
|
|
||||||
|
|
||||||
private string _windowClassName;
|
private string _windowClassName;
|
||||||
|
|
||||||
private int _wmTaskbarCreated;
|
private int _wmTaskbarCreated;
|
||||||
@@ -494,7 +490,7 @@ public class NotifyIcon : FrameworkElement, IDisposable
|
|||||||
_isTransparent = isTransparent;
|
_isTransparent = isTransparent;
|
||||||
var data = new InteropValues.NOTIFYICONDATA
|
var data = new InteropValues.NOTIFYICONDATA
|
||||||
{
|
{
|
||||||
uCallbackMessage = WmTrayMouseMessage,
|
uCallbackMessage = InteropValues.WM_TRAYMOUSEMESSAGE,
|
||||||
uFlags = InteropValues.NIF_MESSAGE | InteropValues.NIF_ICON | InteropValues.NIF_TIP,
|
uFlags = InteropValues.NIF_MESSAGE | InteropValues.NIF_ICON | InteropValues.NIF_TIP,
|
||||||
hWnd = _messageWindowHandle,
|
hWnd = _messageWindowHandle,
|
||||||
uID = _id,
|
uID = _id,
|
||||||
@@ -577,8 +573,8 @@ public class NotifyIcon : FrameworkElement, IDisposable
|
|||||||
_dispatcherTimerPos.Start();
|
_dispatcherTimerPos.Start();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NIN_BALLOONUSERCLICK:
|
case InteropValues.NIN_BALLOONUSERCLICK:
|
||||||
RaiseEvent(new RoutedEventArgs(BalloonTipClickedEvent));
|
RaiseEvent(new RoutedEventArgs(BalloonTipClickEvent));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -676,13 +672,14 @@ public class NotifyIcon : FrameworkElement, IDisposable
|
|||||||
remove => RemoveHandler(MouseDoubleClickEvent, value);
|
remove => RemoveHandler(MouseDoubleClickEvent, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly RoutedEvent BalloonTipClickedEvent =
|
public static readonly RoutedEvent BalloonTipClickEvent =
|
||||||
EventManager.RegisterRoutedEvent("BalloonTipClicked", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(NotifyIcon));
|
EventManager.RegisterRoutedEvent("BalloonTipClick", RoutingStrategy.Bubble, typeof(RoutedEventHandler),
|
||||||
|
typeof(NotifyIcon));
|
||||||
|
|
||||||
public event RoutedEventHandler BalloonTipClicked
|
public event RoutedEventHandler BalloonTipClick
|
||||||
{
|
{
|
||||||
add { AddHandler(BalloonTipClickedEvent, value); }
|
add => AddHandler(BalloonTipClickEvent, value);
|
||||||
remove { RemoveHandler(BalloonTipClickedEvent, value); }
|
remove => RemoveHandler(BalloonTipClickEvent, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateDataContext(FrameworkElement target, object oldValue, object newValue)
|
private void UpdateDataContext(FrameworkElement target, object oldValue, object newValue)
|
||||||
|
|||||||
@@ -83,9 +83,11 @@ internal class InteropValues
|
|||||||
MF_BYPOSITION = 0x400,
|
MF_BYPOSITION = 0x400,
|
||||||
MF_GRAYED = 0x00000001,
|
MF_GRAYED = 0x00000001,
|
||||||
MF_SEPARATOR = 0x800,
|
MF_SEPARATOR = 0x800,
|
||||||
|
NIN_BALLOONUSERCLICK = WM_USER + 5,
|
||||||
TB_GETBUTTON = WM_USER + 23,
|
TB_GETBUTTON = WM_USER + 23,
|
||||||
TB_BUTTONCOUNT = WM_USER + 24,
|
TB_BUTTONCOUNT = WM_USER + 24,
|
||||||
TB_GETITEMRECT = WM_USER + 29,
|
TB_GETITEMRECT = WM_USER + 29,
|
||||||
|
WM_TRAYMOUSEMESSAGE = WM_USER + 1024,
|
||||||
VERTRES = 10,
|
VERTRES = 10,
|
||||||
DESKTOPVERTRES = 117,
|
DESKTOPVERTRES = 117,
|
||||||
LOGPIXELSX = 88,
|
LOGPIXELSX = 88,
|
||||||
|
|||||||
Reference in new issue
Block a user