Search code examples
delphidelphi-7mouse-cursor

Delphi How to get cursor position on a control?


I want to know the position of the cursor on a TCustomControl. How does one go about finding the coordinates?


Solution

  • You can use MouseMove event:

    procedure TCustomControl.MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    begin
      Label1.Caption := IntToStr(x) + ' ' + IntToStr(y);       
    end;