Главная страница | назад





Article #17871: Simulating a mouse move in code.

 Question and Answer Database

FAQ2871D.txt   Simulating a mouse move in code.
Category   :VCL
Platform    :All
Product    :All 32 bit  

Question:
Some components do not respond to a cursor change 
until the user moves the mouse. Is there a way to simulate 
a mouse move?

Answer:
The following example shows how to "nudge the mouse" 
without user intervention.

procedure TForm1.Button1Click(Sender: TObject);
var
  pt : TPoint;
begin
   Application.ProcessMessages;
   Screen.Cursor := CrHourglass;
   GetCursorPos(pt);
   SetCursorPos(pt.x + 1, pt.y + 1);
   Application.ProcessMessages;
   SetCursorPos(pt.x - 1, pt.y - 1);
end;

7/16/98 4:31:28 PM
 

Last Modified: 01-SEP-99