FindControl method

Applies to
TGUITestCase

Declaration
Function FindControl(Comp: TComponent; const CtlName: string): TControl;

Implementation

function TGUITestCase.FindControl(Comp: TComponent; const CtlName: string): TControl;

  function DoFind(C :TComponent; const CName :string) :TControl;
  var
    i: Integer;
  begin
    Result := nil;
    i := 0;
    while (Result = nil) and (i < C.ComponentCount) do
    begin
      with C do
      begin
        if (Components[i] is TControl)
        and (UpperCase(Components[i].Name) = CName) then
          Result := Components[I] as TControl
        else
          Result := DoFind(Components[I], CName);
      end;
      Inc(i);
    end;
  end;
begin
  Assert(Trim(CtlName) <> '', 'No control name');

  Result := DoFind(Comp, UpperCase(CtlName));

  Assert(Result <> nil, Format('Control named "%s" not found', [CtlName]));
End;


HTML generated by Time2HELP
http://www.time2help.com