Delphi中获取客户区坐标


本文整理自网络,侵删。

 procedure TForm1.Timer1Timer(Sender: TObject);
var
handle,hchild1,hchild2:THandle;
ahwnd:hwnd;
point:TPoint;
temp:array[0..255] of char;
rec:Trect;
RGB:integer;
DC :integer;
begin

//取得当前鼠标的位置
GetCursorPos(point);
//取得当前鼠标所在窗体的句柄

handle:=WindowFromPoint(point);
Label1.caption:='当前鼠标坐标:'+inttostr(Point.X)+':'+inttostr(Point.Y )+ ' ';
GetWindowRect(handle,rec);
Label2.caption:='REC:'+inttostr(rec.Left)+':'+inttostr(rec.Top)+' ';
Label3.caption:='客户区坐标:'+inttostr(Point.X -rec.Left )+':'+inttostr(Point.Y -rec.Top)+ ' ';
///////////////////////////////////////////
ahwnd := GetParent(handle);
Label4.caption:=inttostr(ahwnd);
DC:= GetDC(aHwnd);
RGB:= GetPixel(DC,Point.X -rec.Left,Point.Y -rec.Top) ;
Label5.Caption :='目标RGB:'+inttostr(RGB)+' ';
end;

end.

相关阅读 >>

Delphi 在内存中直接运行exe类型的资源文件

Delphi zlib 流压缩解压

Delphi 使用windows api(wincrypt)计算文件md5哈希,支持大文件

Delphi中ocx的动态注册方法

datasnap服务器如何得到客户端的ip和端口

Delphi 简单的字符串加密和解密

Delphi中combobox.items.indexof用法

Delphi字符串旋转任意角度

Delphi xe5 android手机端转换ansi字符串

Delphi xe webbroker 开发,解决 response 返回中文乱码问题

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



打赏

取消

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

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

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

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

评论

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