I have this code, that simulates a mouse drag, moving the form:
procedure TForm1.SimulateMouseDrag(FromX, FromY, ToX, ToY: Integer);
begin
SetCursorPos(Fromx, Fromy);
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0); // Simulate mouse down
sleep(100);
mouse_event(MOUSEEVENTF_MOVE, ToX-FromX, ToY-FromY, 0, 0); // Simulate mouse move
sleep(100);
SetCursorPos(Tox, Toy);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // Simulate mouse up
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SimulateMouseDrag(left+5, top+5, left+200, top+200);
end;
It works, but the form shrinks during the operation. What am I missing?