Archived

This topic is now archived and is closed to further replies.

DanielH

Get mouse pos on TPaintBox

Recommended Posts

Alimonster    185
Could you clarify what you need? I may have misunderstood you here, but why not just use the X and Y parameters of the paintbox''s OnMouseMove event?

Share this post


Link to post
Share on other sites
MButchers    123
Hello there,

if you dont want to use a MouseMove event you could use the following

procedure TForm1.Timer1Timer(Sender: TObject);
var
p: TPoint;
begin
//get the position of the cursor on the screen
GetCursorPos(p);
//convert to controls coordinates
p := PaintBox1.ScreenToClient(p);
//output
Caption := Format(''x %d : y %d'',[p.X,p.Y]);
end;

Mark

Share this post


Link to post
Share on other sites