I have WPF desktop application which is pushing some notifications using:
NotifyIcon.ShowBalloonTip(,,,ToolTipIcon.None)
.
The problem is:
Windows 10 uses new "Windows 10 rectangle with image and text" style for Balloon notifications (I don't know how exactly it is called).
If I use ToolTipIcon.None
parameter, it gets my application icon which was set to NotifyIcon.Icon
property and shows it in this Balloon notification. And this icon is blurred/stretched (like too small icon was taken and stretched to size which is needed for this ballon image).
My ico-file contains several sizes: 16*16, 32*32, 128*128, 256*256
etc. I've already tried to set icon file with only one 128*128
size, but it didn't work.
Should it work at all?
Thank you.
The following class should display a smooth, large icon in the balloon tip on Windows 10. It's by no means polished, but it should prove the concept. A good portion of the code is copied directly from the decompiled Microsoft NotifyIcon class.
The key changes between the original NotifyIcon class and this are:
NOTIFYICONDATA.hBalloonIcon
member.nOTIFYICONDATA.dwInfoFlags = NIIF_LARGE_ICON | NIIF_USER
, instead ofNIIF_NONE
.You can read the specifics of the NOTIFYICONDATA structure here, but the gist is:
hBalloonIcon
was added in Vista, specifically for use outside of the system tray.NIIF_USER
says to use the icon inhBalloonIcon
as the balloon icon.NIIF_LARGE_ICON
says that the balloon's icon should be large.NotifyIconLarge class:
Declare it somewhere:
Then use it like this:
When finished, remove the tray icon: