unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
FIndexOfHandle:Integer;
FArrHandle:Array of THandle;
FStrings:TStrings;
function MyEnumChild(AHwnd: THandle; AParam: Cardinal):Boolean;stdcall;
implementation
{$R *.dfm}
function MyEnumChild(AHwnd: THandle; AParam: Cardinal):Boolean;
var
lPChar:PChar;
str:string;
begin
SetLength(FArrHandle,FIndexofHandle+1);
FArrHandle[FIndexOfHandle] := AHwnd;
GetMem(lPChar,256);
GetClassName(AHwnd,lpchar,256);
FStrings.Add(lpChar);
FreeMem(lPChar);
Inc(FIndexOfHandle);
Result := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
lhwd:THandle;
begin
lhwd := FindWindow('ATL:006CDD10',nil);
if lhwd =0 then Exit;
FStrings := TStringList.Create;
if EnumChildWindows(lhwd,@MyEnumChild,110) then
begin
ShowMessage('Successed');
listbox1.Items.Assign(FStrings);
end;
FStrings.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
button1.Caption:='遍例所有的控件'
end;
end.
Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号
执行时间: 0.039026021957397 seconds