Delphi SetCursorPos函数在窗口上定位鼠标坐标


本文整理自网络,侵删。

 

var

P: TPoint;

ahwnd:hwnd;

rec:Trect;

begin

GetCursorPos(P);

//取得当前鼠标所在窗体的句柄

ahwnd:=WindowFromPoint(P);

GetWindowRect(form1.Handle,rec);

Self.Caption :='桌面坐标'+ Format('X: %d, Y: %d',[P.X, P.Y])+' REC:'+inttostr(rec.Left)+':'+inttostr(rec.Top)+' '+'客户区坐标:'+inttostr(p.X -rec.Left )+':'+inttostr(p.Y -rec.Top)+ ' ';


SetCursorPos(form1.Left+inttostr(p.X -rec.Left ),form1.Top+inttostr(p.X -rec.Top));

相关阅读 >>

Delphi try except语句 和 try finally语句用法以及区别

Delphi提取二值图像轮廓

Delphi ifileoperation替换shfileoperation

Delphi 自带的字符串分割函数

Delphi 建立快捷方式的函数: createshortcut

Delphi datetimepicker控件日期格式

Delphi lastdelimiter:在字符串中查找选定的字符最后出现的位置

Delphi 常用api 函数

Delphi应用synedit完美实现sql语法高亮

Delphi 如何产生输出一个变形的图形及文字

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...