tags:

views:

257

answers:

0

I have a C# application with a NotifyIcon. When user hovers over the Icon, I want to show some pop-up window with stuff in it. Ideally, it would work like a tooltip, or like the network icon in Vista: Appear above the taskbar when you hover over the icon, and disappear when you move out of the icon.

Problem 1

I want to show the popup above wherever the icon is (including in Windows 7, where the icon might be above the taskbar), but I don't know the location of the icon.

Solution: I popup in the location of the Mouse (from the MouseMove event).

Problem with solution: The popup's location varies slightly depending on the mouse's location, and also can obscure other icons.

Problem 2

NotifyIcon only publishes the MouseMove event, which I get whenever the mouse hovers over the icon. I don't get anything when the mouse leaves the icon.

Solution: When I get the first MouseMove, I show the popup, and setup a every-10ms timer. The timer checks whether the mouse is farther than 10 pixels from its location during the initial MouseMove, and if so hides the popup.

Problem with solution: This 20X20 box isn't the same like the icon itself, so the popup disappearance looks a little weird sometimes.

Anybody has better solutions to either problem?