Getting a ReadOnly Published property in Delphi using RTTI without exceptions

  Kiến thức lập trình

I want to use RTTI to determine if a control is read-only. My code currently looks like this and works fine.

function ControlIsReadOnly(const Control: TControl): Boolean;
var
  Value: Variant;
begin
  try
    Value := GetPropValue(Control, 'ReadOnly');
    Result := Value;
  except
    Result := False;
  end;
end;

Is there a nice way to do this without raising an exception if the property is absent?

LEAVE A COMMENT