type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
function ismywindow(hw:HWND;FormClass: TFormClass):boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
if ismywindow(form1.Handle,tform1 ) then
showmessage(form1.ClassName);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
hclass:string;
begin
SetLength(hclass,50);
if iswindow(form1.Handle) then
begin
GetClassName(form1.Handle,pchar(hclass),50);
showmessage(hclass);
end ;
end;
function TForm1.ismywindow(hw: HWND;FormClass: TFormClass): boolean;
var
hclass:string;
begin
result:=false;
setlength(hclass,50);
if iswindow(hw) then
begin
GetClassName(hw,pchar(hclass),50);
hclass:=Trim(string(pchar(hclass)));
if hclass=formclass.ClassName then result:=true;
end;
end;