Recent

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

aydın

  • New Member
  • *
  • Posts: 29
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.
Windows 10 64bit and FPC v3.2.2 and Lazarus 2.2.6

Thaddy

  • Hero Member
  • *****
  • Posts: 12976
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.
I actually get compliments for being rude... (well, Dutch, but that is the same)

aydın

  • New Member
  • *
  • Posts: 29
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+}".
Windows 10 64bit and FPC v3.2.2 and Lazarus 2.2.6

jamie

  • Hero Member
  • *****
  • Posts: 5362
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