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

后端 未结 4 1478
遥遥无期
遥遥无期 2021-01-01 23:15

In a TImage\'s OnClick event, I would like to extract the x,y coordinates of the mouse. I would prefer them in relation to the image, but in relation to the form or window i

4条回答
  •  死守一世寂寞
    2021-01-01 23:47

    As others have said, you can use Mouse.CursorPos or the GetCursorPos function, but you can also just handle the OnMouseDown or OnMouseUp event instead of OnClick. This way you get your X and Y values as parameters to your event handler, without having to make any extra function calls.

提交回复
热议问题