如何枚举窗体的所有控件。欢迎讨论。

zhouqinppq0830 2011-10-20 08:57:08
a.exe 加载了 b.dll(a和b都是delphi所写,其中b.dll被加载后show出一个窗体,窗体上有若干控件,Label,button,textbox等),现在有什么办法能枚举b.dll窗体的所有控件。
...全文
218 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhouqinppq0830 2011-10-28
  • 打赏
  • 举报
回复
我已经完美实现了。谢谢。
zhang_y_b 2011-10-24
  • 打赏
  • 举报
回复
写个回调函数:
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;
zhang_y_b 2011-10-24
  • 打赏
  • 举报
回复
1楼的方法应该可行。
meegowei1 2011-10-22
  • 打赏
  • 举报
回复
sForm 是 self
爱蹄子的羊头 2011-10-21
  • 打赏
  • 举报
回复
b.dll 里面写一个方法 或者 回调才行..不然没办法直接枚举


sForm.ComponentCount
meegowei1 2011-10-21
  • 打赏
  • 举报
回复
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

End ;
End ;

D_Parent 2011-10-20
  • 打赏
  • 举报
回复
用FindWindow找窗体,用EnumChildWindows找控件

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧