您现在的位置:首页 >> API >> API >> 内容

Delphi中获取客户区坐标

时间:2011/9/3 14:53:01 点击:

  核心提示:procedure TForm1.Timer1Timer(Sender: TObject);var handle,hchild1,hchild2:THandle; ahwnd:hwnd; point:...

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.

作者:网络 来源:转载
共有评论 0相关评论
发表我的评论
  • 大名:
  • 内容:
本类推荐
  • 没有
本类固顶
  • 没有
  • 盒子文章(www.2ccc.com) © 2024 版权所有 All Rights Reserved.
  • 沪ICP备05001939号