Win32: Refreshing the tool tip for an icon in the notification area

Started by
4 comments, last by ApochPiQ 18 years, 1 month ago
My app got an icon in the notification area. I'm chaning the text for the tool tip frequently. The problem is that if the tool tip is shown (i.e mouse cursor on icon) when I change the text, it doesn't change. The user needs to move the cursor away from the icon and then back again to get the new text. There must be an easy way to "refresh" the text, how? I'm using Shell_NotifyIcon(NIM_MODIFY, m_nid) to change the text of the tool tip.
Advertisement
I don't know of a specific way to accomplish this; it may require doing some hacking around in the shell code outside the realm of documented APIs. Best thing I can think of is to try using EnumWindows to find the tooltip window, and forcefully close/destroy it - but I don't know if that would convince the shell to re-display the tip. What happens if you send NIM_MODIFY once to remove the tooltip entirely, then send it again to re-add it?

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

AFAIK there is no easy way to do that. After all, tips don't tend to update anywhere else in the OS, either.
ApochPiQ: Gonne try that in the morning, too late here now :) My guess though is that it won't show up at all (it will simply be removed) before I move the mouse.

Bob Janova: Good to know, I was just worried that I missed something in the docs...

I'm sure I can hack it in there, just wanted to check if I missed something obvious.
It's not that crucial to get it to work, but it would have been nicer since I show a progress meter.
If I find the time I'll try to hack it...
A dirty way maybe to set a timer to send a redraw message to the window
This might work. I've not tried it but I'd imagine it'd work.

So InvalidateRect(hwnd, NULL, TRUE); //redraw entire client area, and erase the background
Quote:Original post by anonuser
A dirty way maybe to set a timer to send a redraw message to the window
This might work. I've not tried it but I'd imagine it'd work.

So InvalidateRect(hwnd, NULL, TRUE); //redraw entire client area, and erase the background



It's possible that would work, but unlikely. Tooltip windows are created initially with the text to display, and retain that text during their lifetime; so the logical implementation would be to have them store a copy of the display text. Invalidating the drawing area is unlikely to get them to retrieve the correct text (although a WM_SETTEXT has an off chance of doing it). The other problem is, if the width of the tooltip needs to change, this is almost guaranteed to not resize it correctly.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

This topic is closed to new replies.

Advertisement