Endless calls of Control.OnMouseMove after calling Refresh
I was overriding the OnMouseMove method to write the current coordinates to my control. The problem is that I have to trigger the OnPaint method to refresh the values. If I use Refresh (开发者_开发知识库or even Invalidate) in the OnMouseMove an endless cascade of MouseMove events is triggered. Even if I don't move the mouse the events are raised with X and Y values zero. Why is that? And is there a better way to handle my problem than checking whether X and Y are zero before calling Refresh?
Thanks for help, Werner
I'm using .Net 3.5 on Windows XP and this topic is referring to System.Windows.Forms.
Does your event handling cause another OnPaint invocation? Are you debugging where switching between VS.Net and your app is causing the repaint each time you hit the break point?
精彩评论