Error Delphi OTA and RTTI

I am writing a Delphi expert. I need to write a property value for a property that is an object. For instance. I have a GroupBox in the form, and I want to change the Margins.Left property. I use the following procedure for this, but if you give AV on the marked line.

The procedure takes a component from (the property editor) the name of the property (for example, "Margins.Left") and the new value, analyzes the name of the property, retrieves the object, reads the current value and tries to change it if another. He then calls a method to record any changes.

procedure EditIntegerSubProperty(Component: IOTAComponent;const PropName: String;NewValue: Integer);
var AnObject: TObject;
  TK: TTypeKind;
  At: Integer;
  AClassName, APropName: String;
  PropInfo: PPropInfo;
  OldValue: Integer;
begin
  At := Pos('.', PropName);
  if At < 1 then
  raise Exception.Create('Invalid SubProperty Name: '+PropName);

  AClassName := Copy(PropName, 1, At-1);
  APropName := Copy(PropName, At+1, length(PropName));

  TK := Component.GetPropTypeByName(AClassName);
  if TK <> tkClass then
    EXIT;

  AnObject := GetObjectProp((Component as INTAComponent).GetComponent, AClassName);
  if PropIsType(AnObject, APropName, tkInteger) then
  begin
    OldValue := GetInt64Prop(AnObject, APropName);
    if OldValue <> NewValue then
    begin
      SetInt64Prop(AnObject, APropName, NewValue);  <----AV HERE
      ChangeLogInteger(Name, PropName, OldValue, NewValue);
    end;
  end;
end;
+3
source share
2 answers

Margins.xyzzy - Integer, Int64, GetOrdProp/SetOrdProp .

SetInt64Prop 64- setterter 64- . 32- , , , AV.

, PropIsType.

  • tkInt64: Get/SetInt64Prop
  • tkInteger: Get/SetOrdProp

Get/SetOrdProp Char WideChar, , 100% .

+3

GetOrdProp, SetOrdProp GetInt64Prop, SetInt64Prop?

+3

Source: https://habr.com/ru/post/1697604/


All Articles