当前位置:首页 > 网络编程 > 软件语言 > DELPHI > 获取当前鼠标位置的类名和句柄

获取当前鼠标位置的类名和句柄

点击次数:43 次 发布日期:2008-11-09 08:41:52 作者:源代码网
源代码网推荐
广告载入中
  这有点像金山词霸的屏幕取词。要获取当前鼠标位置的类名和句柄,只须通过 WindowFromPoint
源代码网推荐
源代码网推荐 和GetClassName 这两个Win32函数就可以完成任务,不过,如果要获取当前鼠标位置的字符,可能要复杂得多。
源代码网推荐
源代码网推荐 下面是很简单的范例,大家应该都可以轻易弄清楚的。
源代码网推荐
源代码网推荐  
源代码网推荐
源代码网推荐 type
源代码网推荐 TForm1 = class(TForm)
源代码网推荐 NameLB: TLabel;
源代码网推荐 ClassLB: TLabel;
源代码网推荐 Timer1: TTimer;
源代码网推荐 procedure Timer1Timer(Sender: TObject);
源代码网推荐 procedure FormCreate(Sender: TObject);
源代码网推荐 private
源代码网推荐 procedure GetMousePosHwndAndClassName(Sender : TPoint);
源代码网推荐 public
源代码网推荐
源代码网推荐 end;
源代码网推荐
源代码网推荐 var
源代码网推荐 Form1: TForm1;
源代码网推荐
源代码网推荐 implementation
源代码网推荐
源代码网推荐 {$R *.DFM}
源代码网推荐
源代码网推荐 procedure TForm1.Timer1Timer(Sender: TObject);
源代码网推荐 var
源代码网推荐 rPos: TPoint;
源代码网推荐 begin
源代码网推荐 if boolean(GetCursorPos(rPos)) then
源代码网推荐 GetMousePosHwndAndClassName(rPos);
源代码网推荐 end;
源代码网推荐
源代码网推荐 procedure TForm1.GetMousePosHwndAndClassName(Sender: TPoint);
源代码网推荐 var
源代码网推荐 hWnd: THandle;
源代码网推荐 aName: array [0..255] of char;
源代码网推荐 begin
源代码网推荐 hWnd := WindowFromPoint(Sender);


源代码网推荐 NameLB.Caption := ’Handle : ’ IntToStr(hWnd);
源代码网推荐
源代码网推荐 if boolean(GetClassName(hWnd, aName, 256)) then
源代码网推荐 ClassLB.Caption := ’ClassName : ’ string(aName)
源代码网推荐 else
源代码网推荐
源代码网推荐 ClassLB.Caption := ’ClassName : not found’;
源代码网推荐 end;
源代码网推荐
源代码网推荐 procedure TForm1.FormCreate(Sender: TObject);
源代码网推荐 begin
源代码网推荐 Form1.FormStyle := fsStayOnTop;
源代码网推荐 Timer1.Interval := 50;
源代码网推荐 end;


源代码网推荐

源代码网供稿.
网友评论 (0)
会员中心
网络编程
本站推荐
网络编程之精华