'Should OnMouseMove events arrive endlessly?
I'm trying to handle OnMouseMove in Delphi (XE3) and even when I don't move the mouse I get endless stream of OnMouseMove events, one after another.
Ex.: start new VCL Forms Application. Add OnMouseMove handler to the form with this code:
var s: string;
begin
s := IntToStr(GetTickCount()) + ': MouseMove';
OutputDebugString(PChar(s));
end;
Place the mouse over the form, observe endless OnMouseMoves in IDE's Messages log.
I would expect MouseMove messages to only arrive when I actually move the cursor (and maybe at some other exceptional situations). In fact, i've always though OnMouseMove worked this way.
Am I doing something wrong? Is this correct from a Delphi standpoint (i.e. by design)? Is this correct by WinAPI? What to do about it?
Solution 1:[1]
I can add a tip, OnMouseMove events arrive endlessly also when you show a Hint over the control.
I discovered the hard way: I was trying to show a hint when mouse moves over each element of a ListBox showing some 'extra' information about that element.
As soon as i call HintWindow.ActivateHint(...,HintWindow.Hint); the OnMouseMove is set to be triggered.
Since the first thing io do inside the OnMouseMove is to free and recreate the HintWindow, the Hint flickers a lot because OnMouseMove events arrive endlessly.
If i set OnMouseMove to Nil prior to .ActivateHint, the flicker ends and no more OnMouseMove events arrive.
Now i am trying to 'save' the event into a variable and restore after .ActivateHint, but i am not sure how to do it and what effect will have ... saving OnMouseLeave is easy, but OnMouseMove raises a compiler error Parameter List Differs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Laura |
