【问题标题】:C++ Builder 2009 Iterate/Recurse through Components on a FormC++ Builder 2009 迭代/递归表单上的组件
【发布时间】:2014-01-01 18:08:58
【问题描述】:

我希望遍历/递归表单上的组件。

我计划对组件进行迭代/递归以对特定类型的组件进行批量更改,但为此,我需要处理所有组件。

我检查了 Code Complete 和 Google,但没有任何运气回答我自己的问题。

【问题讨论】:

标签: components c++builder c++builder-2009


【解决方案1】:

使用TWinControl.Controls[] 属性,例如:

Procedure DoSomething(AControl: TWinControl);
Var
  I: Integer;
  Ctrl: TControl;
Begin
  If AControl is TSomeControl then
  Begin
    ...
  End;
  For I := 0 to AControl.ControlCount-1 do
  Begin
    Ctrl := AControl.Controls[I];
    If Ctrl is TWinControl then
      DoSomething(TWinControl(Ctrl));
  End; 
End;

Procedure TMyForm.DoIt;
Begin
  DoSomething(Self);
End;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-05
    • 1970-01-01
    • 2011-05-11
    • 1970-01-01
    • 2021-02-09
    • 1970-01-01
    相关资源
    最近更新 更多