NotifyIcon - MouseEnter/Leave?

Archives Forums/Win32 Discussion/NotifyIcon - MouseEnter/Leave?

Grisu(Posted 2009) [#1]
Hi guys!

My app displays a tooltip bubble over the apps taskbar icon.
I need to detect if a user moves the mouse over the taskbar icon or leaves it. This way I want to change the infomation given inside the bubble each time the user "refreshes" the bubble.

Is this possible? How?

Currently I use a timer for this, but it eats too much cpu power for my taste... I'm a perfectionist... ;)

Grisu


Brucey(Posted 2009) [#2]
Can't you just refresh it every time the track changes?

That's what I do with mine :-p


Grisu(Posted 2009) [#3]
Well, I also display the station name and the song titles.

Also, why refresh it every time the song changes, if the user isn't even watching these informations?

I often run PRP minimised while playing games. So why update the tooltips then? :o)


Brucey(Posted 2009) [#4]
So why update the tooltips then?

Well, one function call every 2 mins or so shouldn't be obvious in the great scheme of things.

Otherwise you specifically have to intercept the mouse-entry on the systray, go and find the details of the text you want to show, and feed it into the tooltip before it shows.

You're catching up though!
Not long now until you're as bloated as mine ;-)


Grisu(Posted 2009) [#5]
You're catching up though!

I take this as compliment from you... ;)

Never thought I would invest so much time in this little app.

I like optimising stuff. At least to find out that my solution is already the best for the purpose. :)


_PJ_(Posted 2009) [#6]
As far as I understand, Tooltips are automatically displayed by the 'internals' of the API. I dunno about earlier Visual Basic versions, but with .NET at least, tooltips can be dynamically linked.

I found this here which describes 'balloon messages' too, which I think can be set to change on time with little resource eating:


Balloon messages
Tray icons may ask the system tray to display a balloon message to the user. The system tray coordinates balloon messages to ensure that they have a consistent look-and-feel, and to avoid displaying multiple balloon messages at once.

A balloon message is a short text message to be displayed to the user. The message may have a timeout; if so, the message will be taken down after the timeout expires. Messages are displayed in a queue, as only one can appear at a time; if a message has a timeout, the timer begins when the message is first displayed. Users may be allowed to close messages at any time, and may be allowed to disable all message display.

System trays may display balloon messages in any way they see fit; for example, instead of popping up a balloon, they could choose to put a special indicator around icons with pending messages, and display the message on mouseover.

Balloon messages are sent from the tray icon to the system tray selection owner window as a series of client messages. The first client message is an opcode message, and contains the usual timestamp, and the op code SYSTEM_TRAY_BEGIN_MESSAGE. xclient.data.l[2] contains the timeout in thousandths of a second or zero for infinite timeout, xclient.data.l[3] contains the length of the message string in bytes, not including any nul bytes, and xclient.data.l[4] contains an ID number for the message. This ID number should never be reused by the same tray icon. (The simplest way to generate the ID number is to increment it with each message sent.)

Following the SYSTEM_TRAY_BEGIN_MESSAGE op code, the tray icon should send a series of client messages with a message_type of _NET_SYSTEM_TRAY_MESSAGE_DATA. These client messages must have their window field set to the window ID of the tray icon, and have a format of 8.

Each _NET_SYSTEM_TRAY_MESSAGE_DATA message contains 20 bytes of the message string, up to the length given in the SYSTEM_TRAY_BEGIN_MESSAGE opcode. If the message string is zero-length, then no messages need be sent beyond the SYSTEM_TRAY_BEGIN_MESSAGE. A terminating nul byte should never be sent.

System trays may receive portions of messages from several tray icons at once, so are required to reassemble the messages based on the window ID of the tray icon.

The tray icon may wish to cancel a previously-sent balloon message. To do so, it sends a SYSTEM_TRAY_CANCEL_MESSAGE opcode with data.l[2] set to the ID number of the message to cancel.




Grisu(Posted 2009) [#7]
I only have these 3 options:
NIM_ADD - Adds an icon to the status area.
NIM_DELETE - Deletes an icon from the status area.
NIM_MODIFY - Modifies an icon in the status area.

See: http://msdn.microsoft.com/en-us/library/aa922175.aspx

It would be great to be able to force a refresh of the ballon tip though.
Currently the user has to rehover over the icon to make the changes visible.