Skip to content
Open
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="HandyControlDemo.UserControl.NotifyIconDemo"
<UserControl x:Class="HandyControlDemo.UserControl.NotifyIconDemo"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Expand Down Expand Up @@ -54,6 +54,9 @@
<hc:EventTrigger EventName="MouseDoubleClick">
<hc:EventToCommand Command="{Binding MouseCmd}" CommandParameter="MouseDoubleClick"/>
</hc:EventTrigger>
<hc:EventTrigger EventName="BalloonTipClicked">
<hc:EventToCommand Command="hc:ControlCommands.PushMainWindow2Top"/>
</hc:EventTrigger>
</hc:Interaction.Triggers>
</hc:NotifyIcon>
<hc:NotifyIcon Token="{x:Static data:MessageToken.NotifyIconContextDemo}" x:Name="NotifyIconContextContent" Text="HandyControl" IsBlink="{Binding ContextContentIsBlink}" Visibility="{Binding ContextContentIsShow,Converter={StaticResource Boolean2VisibilityConverter}}" Icon="/HandyControlDemo;component/Resources/Img/icon-white.ico">
Expand All @@ -75,6 +78,9 @@
<hc:EventTrigger EventName="MouseDoubleClick">
<hc:EventToCommand Command="{Binding MouseCmd}" CommandParameter="MouseDoubleClick"/>
</hc:EventTrigger>
<hc:EventTrigger EventName="BalloonTipClicked">
<hc:EventToCommand Command="hc:ControlCommands.PushMainWindow2Top"/>
</hc:EventTrigger>
</hc:Interaction.Triggers>
</hc:NotifyIcon>
</hc:SimplePanel>
Expand Down
6 changes: 4 additions & 2 deletions src/Shared/HandyControl_Shared/Controls/Other/NotifyIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ public void ShowBalloonTip(string title, string content, NotifyIconInfoType info

var data = new InteropValues.NOTIFYICONDATA
{
uFlags = InteropValues.NIF_INFO,
uFlags = InteropValues.NIF_INFO | InteropValues.NIF_MESSAGE,
hWnd = _messageWindowHandle,
uID = _id,
szInfoTitle = title ?? string.Empty,
szInfo = content ?? string.Empty
szInfo = content ?? string.Empty,
uCallbackMessage = InteropValues.WM_TRAYMOUSEMESSAGE
};

data.dwInfoFlags = infoType switch
Expand All @@ -163,6 +164,7 @@ public void ShowBalloonTip(string title, string content, NotifyIconInfoType info
NotifyIconInfoType.None => InteropValues.NIIF_NONE,
_ => data.dwInfoFlags
};
data.dwInfoFlags |= InteropValues.NIIF_USER;

InteropMethods.Shell_NotifyIcon(InteropValues.NIM_MODIFY, data);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Runtime.InteropServices;
Expand Down Expand Up @@ -50,6 +50,7 @@ internal const int
NIIF_INFO = 0x00000001,
NIIF_WARNING = 0x00000002,
NIIF_ERROR = 0x00000003,
NIIF_USER = 0x00000004,
WM_ACTIVATE = 0x0006,
WM_QUIT = 0x0012,
WM_GETMINMAXINFO = 0x0024,
Expand Down