How can I show a systray tooltip longer than 63 chars? NotifyIcon.Text has a 63 chars limit, but I've seen that VNC Server has a longer tooltip.
How can I do what VNC Server does?
How can I show a systray tooltip longer than 63 chars? NotifyIcon.Text has a 63 chars limit, but I've seen that VNC Server has a longer tooltip.
How can I do what VNC Server does?
Expanding on bk1e's correct answer.
Under the hood, a system tray icon in WinForms is implemented as a Win32 Notify Icon. Therefore the winforms version has all of the limitations as the native one. The tooltip size limitation is just one example.
From the MSDN documentation on the Win32 NOTIFYICONDATA structure:
It looks like the Windows Forms library supports the lowest common denominator here.
bk1e here says that the limit is 128 chars, now, if you use UTF-16, which is the native unicode format in windows and especially .NET, that means you are limited to 64 characters, including the NUL.
I would believe that you're using a unicode API which limits tooltips to 64 16-bit characters (including the null), and that VNC Server uses ascii (or ANSI) api's instead, allowing the use of 128 8-bit characters (including the null).
EDIT: This answer is wrong, here is a helpful comment by Cody Gray explaining why:
I recently came across a similar problem. Rather than hacking the back-end, I implemented a work-around, which makes use of the BalloonTipText, which can accommodate quite a lot of characters.
The tooltip is shown on the first MouseMove event over the tray icon and the tooltip is displayed for 2 seconds. Atter the tooltip is closed, it can be re-opened again by a new MouseMove event.
The only downside with this solution is that is is not possible to close the balloon programatically, when a user, say, leaves the icon area, so it only disappears after a timeout or if the user clicks on the small X-button.
Note that the title and the text can be set at any time elsewhere in the program. They are set here in the event for demonstration purpose only.
EDIT:
ShowBalloonTip()
fires addition cascadingMouseMove
events, so it is necessary to disable this event until such time as the balloon tooltip is hidden. Additionally,BalloonTipClosed
is (according to the documentation) only fired when the user actively clicks on 'X', though I observed it being fired when the tooltip closed after a timeout. I therefore added a helper timer to reset the sate, instead of relying on theBalloonTipClosed
event. The revised and tested code is below:EDIT 2: A screenshot of a balloon tooltip with quite a lot of text, that utilises this solution can be seen in by blog.
Actually, it is a bug in the property setter for the Text property. The P/Invoke declaration for NOTIFYICONDATA inside Windows Forms uses the 128 char limit. You can hack around it with Reflection: