HavenDV / H.NotifyIcon

TrayIcon for WPF/WinUI/Uno/MAUI
MIT License
543 stars 43 forks source link

Tooltip not showing (console app) #25

Open yoyos opened 2 years ago

yoyos commented 2 years ago

Describe the bug

Maybe I missed something but I created a simple TrayIcon with a tooltip+icon Icon is showing correctly but no tooltip appears when moving the mouse over the icon.

Steps to reproduce the bug

trayIcon = new TrayIcon("H.NotifyIcon.Apps.Console.TrayIcon")
            {
                Icon = icon.Handle,
                ToolTip = "ToolTip Info",
                Visibility = IconVisibility.Visible
            };
trayIcon.Create();

Expected behavior

"ToolTip Info" should be displayed on mouse over

Screenshots

No response

NuGet package version

H.NotifyIcon 2.0.50

Platform

Console

IDE

Visual Studio 2022

Additional context

Using .NET 6 and console application.

HavenDV commented 2 years ago

Hello. Thanks for the problem. What version of Windows are you using? I checked on Windows 11, the ToolTip is showing:

image
yoyos commented 2 years ago

Edition Windows 10 Pro Version 21H2 Installed on ‎12/‎01/‎22 OS build 19044.1645 Experience Windows Feature Experience Pack 120.2212.4170.0

wyy272176594 commented 2 years ago

Hello. Thanks for the problem. What version of Windows are you using? I checked on Windows 11, the ToolTip is showing: image

Hi, on my side the custom tooltip (wpf .net5.0) not showing on Windows 11. But it can be shown on Windows 10.

tivereso commented 1 year ago

Apologies if I've got this wrong but the OP appears to be using the TrayIcon, which does not have a handler for the tooltip by default (TrayIcon.MessageWindow.BalloonToolTipChanged).

I think the sample projects may be a little confusing - the H.NotifyIcon.Apps.Wpf.Windowless sample project uses the TaskbarIcon instead of the TrayIcon (and the tooltip works because of the event handler), whilst the H.NotifyIcon.Apps.Console sample project uses TrayIcon that does not include an event handler. Although the console sample includes a tooltip

using var trayIcon = new TrayIconWithContextMenu
{
    Icon = icon.Handle,
    ToolTip = "ToolTip",
};

the console example doesn't have the required code to actually display the said tooltip.

I ran into the same issue as OP so I'm new to understanding this library, is this correct @HavenDV? How does one reference TaskbarIcon from a console project? Although TaskbarIcon has HAS_WPF checks I don't know if it's simple or requires threading more suited to WPF apps.

HavenDV commented 1 year ago

Apologies if I've got this wrong but the OP appears to be using the TrayIcon, which does not have a handler for the tooltip by default (TrayIcon.MessageWindow.BalloonToolTipChanged).

I think the sample projects may be a little confusing - the H.NotifyIcon.Apps.Wpf.Windowless sample project uses the TaskbarIcon instead of the TrayIcon (and the tooltip works because of the event handler), whilst the H.NotifyIcon.Apps.Console sample project uses TrayIcon that does not include an event handler. Although the console sample includes a tooltip

using var trayIcon = new TrayIconWithContextMenu
{
    Icon = icon.Handle,
    ToolTip = "ToolTip",
};

the console example doesn't have the required code to actually display the said tooltip.

I ran into the same issue as OP so I'm new to understanding this library, is this correct @HavenDV? How does one reference TaskbarIcon from a console project? Although TaskbarIcon has HAS_WPF checks I don't know if it's simple or requires threading more suited to WPF apps.

There are two packages here: H.NotifyIcon - Which contains the TrayIcon/TrayIconWithContextMenu classes that are available for use from the console project H.NotifyIcon.Wpf - Contains a TaskbarIcon that is commonly used via xaml. This is a TrayIcon wrapper that allows you to take advantage of WPF.

So far I've tested the console classes on Windows 11 and the tooltip worked correctly. Since this is just a wrapper over the Win32 api, I don't have any ideas yet why this might not work on Windows 10. If there are any additional details, I'd love to hear them.

JasonWei512 commented 1 year ago

Possibly related:

https://github.com/hardcodet/wpf-notifyicon/issues/65#issuecomment-949063289

JasonWei512 commented 1 year ago

Could this be related to Windows 11's new XAML-based system tray?

This is the old GDI system tray:

Old System Tray

This is the new XAML system tray, which has drop shadows, rounded corners, and nicer transition animation:

XAML System Tray

My friend's computer is running Windows 11 stable build, which has the old GDI system tray. On his PC H.NotifyIcon's tooltips work fine.

I have 2 computers, both running Windows 11 Insider Release Preview. I remember that tooltip in console program used to work on both computers, but both stopped working at some point, maybe after Microsoft pushed the new XAML system tray to these 2 computers.

However, it seems that only programs using H.NotifyIcon are affected. The tooltips of all the other programs with system tray icons (Steam, OneDrive, Everything, etc.) on my PC work fine. Maybe there's something special in your implementation?