Lazarus

Programming => General => Topic started by: aydın on March 26, 2023, 03:17:45 pm

Title: How can I access the properties of nested classes?
Post by: aydın on March 26, 2023, 03:17:45 pm
I can access properties except tkClass of a class using RTTI

Code: Pascal  [Select][+][-]
  1. Procedure WriteClass(MyClass: TPersistent; Section: String = '');
  2. Var
  3.   PropList: PPropList;
  4.   PropInfo: PPropInfo;
  5.   PropCount, i: Integer;
  6. Begin
  7.   PropCount:= GetPropList(MyClass.ClassInfo, tkProperties, nil);
  8.   GetMem(PropList, PropCount *SizeOf(PPropInfo));
  9.   Try
  10.     GetPropList(MyClass.ClassInfo, tkProperties, PropList);
  11.  
  12.     For i:= 0 to PropCount-1 do
  13.     Begin
  14.       PropInfo:= PropList^[i];
  15.  
  16.       ShowMessage(Section+PropInfo^.Name+' = '+VarToStr(GetPropValue(MyClass, PropInfo^.Name)))
  17.  
  18.       //For Type: GetEnumName(TypeInfo(TTypeKind), Ord(PropInfo^.PropType^.Kind));
  19.     End;
  20.   Finally
  21.     FreeMem(PropList);
  22.   End;
  23. End;
  24.  

I tried very hard, but couldn't access the properties of nested classes.
I want to do this using xml and of course the bidet will read.

A code or example would be very helpful.
Title: Re: How can I access the properties of nested classes?
Post by: Thaddy on March 26, 2023, 03:22:45 pm
Giving a full example my be much more helpful. First guess: compile in {$M+} state.
But without more info we can not help you.
Title: Re: How can I access the properties of nested classes?
Post by: aydın on March 26, 2023, 03:47:07 pm
I will use this to save Form.

I don't know how to access properties of nested classes but I added the key "{$M+}".
Title: Re: How can I access the properties of nested classes?
Post by: jamie on March 26, 2023, 04:13:36 pm
TFORM has session Properties

You can specify the properties of controls to save and restore later.

TinyPortal © 2005-2018