unit Unit1;
interface
uses
; Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
; StdCtrls, ExtCtrls;
type
; TForm1 = class(TForm)
; ; Edit1: TEdit;
; ; Timer1: TTimer;
; ; Label_ClassName: TLabel;
; ; StaticText1: TStaticText;
; ; procedure Timer1Timer(Sender: TObject);
; private
; ; { Private declarations }
; public
; ; { Public declarations }
; end;
var
; Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Timer1Timer(Sender: TObject);
var
; ClassName: PChar;
; atCursor: TPoint;
; hWndMouseOver: HWND;
; Text: PChar;
begin
; GetCursorPos(atCursor);
; hWndMouseOver:=WindowFromPoint(atCursor);
; GetMem(ClassName, 100);
; GetMem(Text, 255);
; try
; ; GetClassName(hWndMouseOver, ClassName, 100);
; ; SendMessage(hWndMouseOver, WM_GETTEXT, 255, LongInt(Text));
; ; Label_ClassName.Caption:='类名(Classname): '+String(ClassName);
; ; Edit1.Text:=String(Text);
; finally
; ; FreeMem(ClassName);
; ; FreeMem(Text);
; end;
end;
end.
其中Timer控件的interval值为100最佳。在DELPHI5中调试通过。