Recent

Author Topic: How can I access the properties of nested classes?  (Read 498 times)

aydın

  • Jr. Member
  • **
  • Posts: 77
How can I access the properties of nested classes?
« 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.
Lazarus 3.0 on Ubuntu 23.04 and Windows 11

Thaddy

  • Hero Member
  • *****
  • Posts: 14213
  • Probably until I exterminate Putin.
Re: How can I access the properties of nested classes?
« Reply #1 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.
Specialize a type, not a var.

aydın

  • Jr. Member
  • **
  • Posts: 77
Re: How can I access the properties of nested classes?
« Reply #2 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+}".
Lazarus 3.0 on Ubuntu 23.04 and Windows 11

jamie

  • Hero Member
  • *****
  • Posts: 6091
Re: How can I access the properties of nested classes?
« Reply #3 on: March 26, 2023, 04:13:36 pm »
TFORM has session Properties

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

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018