⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unit1.~pas

📁 该功能实现了利用鼠标的移动能够获得鼠标位置的控件的名称和类名
💻 ~PAS
字号:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Timer1: TTimer;
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Timer1Timer(Sender: TObject);
var
 MousePoint: TPoint;
 ControlName: string;
 ControlHandle: integer;
 Pch: Pansichar;
 Twin: TWinControl;
begin
try
 new(Pch);
GetCursorPos(MousePoint);
{
Twin := findvclwindow( mousepoint);
edit1.Text :=twin.Name ;  }

//getcontrolname

ControlHandle := WindowFromPoint(MousePoint);
GetClassName(conTrolHandle,pch,255);
edit1.Text := pch;
dispose(pch);
 {  先getcursorpos
  再WindowFromPoint
  则可得到控件句柄了
  最后getclassname即可。
   FindVCLWindow(}
   except

end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -