Jump to content
  • Advertisement

Archived

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

DanielH

Get mouse pos on TPaintBox

This topic is 5527 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do i get the mouse position starting from 0,0 in the upper left corner of a TPaintBox?

Share this post


Link to post
Share on other sites
Advertisement
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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!