delphi - How do I get the coordinates of the mouse when a control is clicked? -


In the OnClick event of a TImage, I want to remove the mouse X, Y coordinates. I like them in relation to the image, but equally good in terms of form or window.

mouse. The cursor page has TPET, which in turn retains the position of X and Y. This value is in the global coordinates, so you can translate into your form using the ScreenToken routine which will translate the screen coordinates into window coordinates.

According to the Delphi Support File, Windows.GetCursorPos may fail, Mouse.CursorPos wrap it up to increase eosaxation if it fails.

  var pt: tPoint; Start Pt: = Mouse Cursorpage; // Now the screen status label is 1. Caption: = 'X =' + IntToStr (pt.x) + ', Y =' + IntToStr (pt.y); Pt: = Screenshot Client (PT); // Now form position Label2.Caption: = 'X =' + IntToStr (pt.x) + ', Y =' + IntToStr (pt.y); End;  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -