I am using a notify icon control in C# with the .NET Framework 3.5 My goal is to detect when the mouse is hovering over the tray icon of my application. The issue is that there are no mouseenter, mouseleave, or mousehover events for this version. When I attempted to use mousemove and a polling thread to detect if the mouse is hovering over the icon. It returns a x and y location of 0. Is there a reason for this inaccurate location and is there another method for detecting a hover on a notify icon control?
Asked
Active
Viewed 713 times
0
-
Why do you want to know this? What are you going to do in response to this event? – David Heffernan May 04 '12 at 14:00
-
I am going to open a dialog or run a thread upon hovering – John May 04 '12 at 14:09
-
No good way to do it. You can try it with a timer that starts on the first `MouseMove` and timer being disabled, record the initial `Cursor.Position`, start the timer, compare the `Cursor.Position` with your initial value, and if you are farther than 20 pixels-ish from your original x,y position, consider it a leave event and turn off the timer, etc. – LarsTech May 04 '12 at 15:12
-
@LarsTech, your idea is inaccurate, but it did give me an idea to make an array of all the positions of the cursor whenever the mousemove even is fired. Then have a thread that checks if the current cursor is over one of the positions that were logged for over a second. That would solve the problem. If you post a response I will accept it. – John May 04 '12 at 15:19
-
Feel free to post your own solution to this. Not sure about your recording positions idea — a mouse can move pretty far in a few ticks. – LarsTech May 04 '12 at 15:30