DLL 可能不行,不过直接在 delphi 内部,查找所有一个窗口的控件还是可以的var I : Integer ; tmpControl : TControl ; tmpAction : TAction ; tmpMenuItem : TMenuItem ; tmpComponent : TComponent ; tmpBarItem : TdxNavBarItem ; begin For I:=0 To sForm.ComponentCount-1 Do Begin tmpComponent := sForm.Components[I] ; If tmpComponent Is TAction Then Begin tmpAction := tmpComponent As TAction ; //..自己处理代码 End else If tmpComponent Is TControl Then Begin TmpControl := tmpComponent As TControl ; //..自己处理代码 end else If tmpComponent Is TMenuItem Then Begin TmpMenuItem := tmpComponent As TMenuItem ; //..自己处理代码 End else If tmpComponent Is [xxx] Then Begin
写个回调函数: function EnumChildWndProc(AhWnd:LongInt;AlParam:lParam):boolean;stdcall; var WndClassName: array[0..254] of Char; WndCaption: array[0..254] of Char; begin GetClassName(AhWnd,wndClassName,254);//类名 sendmessage(AhWnd,wm_gettext,255,longint(@WndCaption));//标题 mainForm.Memo1.Lines.Add('ClassName:'+string(WndClassName)+';'+'Caption:'+string(WndCaption)); result:=true; end;
I : Integer ;
tmpControl : TControl ;
tmpAction : TAction ;
tmpMenuItem : TMenuItem ;
tmpComponent : TComponent ;
tmpBarItem : TdxNavBarItem ;
begin
For I:=0 To sForm.ComponentCount-1 Do
Begin
tmpComponent := sForm.Components[I] ;
If tmpComponent Is TAction Then
Begin
tmpAction := tmpComponent As TAction ;
//..自己处理代码
End
else
If tmpComponent Is TControl Then
Begin
TmpControl := tmpComponent As TControl ;
//..自己处理代码
end
else
If tmpComponent Is TMenuItem Then
Begin
TmpMenuItem := tmpComponent As TMenuItem ;
//..自己处理代码
End
else
If tmpComponent Is [xxx] Then
Begin
End ;
End ;
sForm.ComponentCount
function EnumChildWndProc(AhWnd:LongInt;AlParam:lParam):boolean;stdcall;
var
WndClassName: array[0..254] of Char;
WndCaption: array[0..254] of Char;
begin
GetClassName(AhWnd,wndClassName,254);//类名
sendmessage(AhWnd,wm_gettext,255,longint(@WndCaption));//标题
mainForm.Memo1.Lines.Add('ClassName:'+string(WndClassName)+';'+'Caption:'+string(WndCaption));
result:=true;
end;