You are using the TypInfo module, more specifically, the IsPublishedProp and GetOrdProp methods.
In your case, it will be something like:
if IsPublishedProp(ACtrl, 'Font') then ModifyFont(TFont(GetOrdProp(ACtrl, 'Font')))
A snippet from one of my libraries that should put you on the right path:
function ContainsNonemptyControl(controlParent: TWinControl; const requiredControlNamePrefix: string; const ignoreControls: string = ''): boolean; var child : TControl; iControl: integer; ignored : TStringList; obj : TObject; begin Result := true; if ignoreControls = '' then ignored := nil else begin ignored := TStringList.Create; ignored.Text := ignoreControls; end; try for iControl := 0 to controlParent.ControlCount-1 do begin child := controlParent.Controls[iControl]; if (requiredControlNamePrefix = '') or SameText(requiredControlNamePrefix, Copy(child.Name, 1, Length(requiredControlNamePrefix))) then if (not assigned(ignored)) or (ignored.IndexOf(child.Name) < 0) then if IsPublishedProp(child, 'Text') and (GetStrProp(child, 'Text') <> '') then Exit else if IsPublishedProp(child, 'Lines') then begin obj := TObject(cardinal(GetOrdProp(child, 'Lines'))); if (obj is TStrings) and (Unwrap(TStrings(obj).Text, child) <> '') then Exit; end; end; //for iControl finally FreeAndNil(ignored); end; Result := false; end; { ContainsNonemptyControl }
source share