本文整理自网络,侵删。
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.
相关阅读 >>
Delphi urldownloadtofile 支持进度条
更多相关阅读请进入《Delphi》频道 >>