Delphi WinAPI: WindowFromPoint- 获取指定点所在窗口的句柄
2023-01-02 12:42:09 作者:admin
本文整理自网络,侵删。
WinAPI: WindowFromPoint- 获取指定点所在窗口的句柄//声明:WindowFromPoint(Point: TPoint): HWND;
//举例:unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
type TForm1 = class(TForm) Button1: TButton; Timer1: TTimer; procedure Timer1Timer(Sender: TObject); end;
var Form1: TForm1;
implementation
{$R *.dfm}
var h: HWND;
procedure TForm1.Timer1Timer(Sender: TObject);var pt: TPoint; arr: array[0..254] of char;begin if GetCursorPos(pt) then {如果能获取点} begin h := WindowFromPoint(pt); {返回句柄} GetClassName(h, arr, Length(arr)); {获取该句柄窗口的类名} Text := arr; {显示在标题} end;end;
end.
//效果图:
相关阅读 >>
Delphi格式化函数format、formatdatetime和formatfloat
Delphi 将strings合并成一个逗号分隔的字符串,用于sql
Delphi文件操作所涉及的一些函数 附例子
Delphi drawing text 绘制文本
Delphi 获取电脑进程网络连接ip端口
Delphi 在线程中运行窗体
Delphi比较两个位图是否相同
Delphi 2009 之 tcategorypanelgroup[5]: headerstyle
Delphi unigui确认对话框
Delphi 禁止窗口移动
更多相关阅读请进入《Delphi》频道 >>
猜你喜欢
联络方式:
400-123-789
邮箱:xiachao@163.com
Q Q:12345678
微信公众号
微信二维码