API function: getcursorpos and conversion

Source: Internet
Author: User
// Obtain the current position of the mouse in the form procedure tform1.formmousedown (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer); var STR: string; begin STR: = format ('% d, % d', [x, y]); showmessage (STR); end;

 // Getcursorpos is used to obtain the position of the mouse relative to the screen. var PS: tpoint; STR: string; begin getcursorpos (PS); STR: = format ('% d, % d', [PS. x, PS. y]); showmessage (STR); end;

 // But the screentoclient method can be used to convert var PS: tpoint; STR: string; begin getcursorpos (PS); PS: = screentoclient (PS); STR: = format ('% d, % d', [PS. x, PS. y]); showmessage (STR); end;

 // Clienttoscreen Function Procedure tform1.formmouseup (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer); var STR: string; PS: tpoint; begin {displays the current mouse position, which is relative to the form} STR: = format ('% d, % d', [x, y]); showmessage (STR ); {the position of the current mouse relative to the screen can be obtained through the clienttoscreen function} PS: = point (x, y); PS: = clienttoscreen (PS); STR: = format ('% d, % d', [PS. x, PS. y]); showmessage (STR); end;

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.