Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
LCL
»
Enumerating properties and methods of a class at runtime with RTTI
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Why does Free Pascal use ...
by
Warfley
[
Today
at 07:45:33 pm]
LRS Explorer
by
Xenno
[
Today
at 07:27:54 pm]
[Solved] The use of EXIT ...
by
440bx
[
Today
at 07:27:20 pm]
Is it possible to communi...
by
Xor-el
[
Today
at 06:46:27 pm]
TEDit PasswordChar not wo...
by
Hansaplast
[
Today
at 05:19:01 pm]
MR - DebuggerIntf for ter...
by
MattBradford
[
Today
at 03:59:36 pm]
Which Linux version
by
cdbc
[August 15, 2026, 08:28:37 pm]
[Qt5/Qt6] JPSupport-Qt: J...
by
shortcut
[August 15, 2026, 08:19:29 pm]
FpDebug: Bugs and API gap...
by
Martin_fr
[August 15, 2026, 08:07:50 pm]
BS Controls – Silly Compo...
by
Xenno
[August 15, 2026, 07:40:44 pm]
Framer: How to get Rid of...
by
ADMGNS
[August 15, 2026, 06:46:33 pm]
Adding persistent fields ...
by
LemonParty
[August 15, 2026, 05:47:05 pm]
Synedit wordwrap
by
Martin_fr
[August 15, 2026, 05:37:57 pm]
TlsLib4Pascal
by
Thaddy
[August 15, 2026, 05:27:52 pm]
array values as reference
by
jamie
[August 15, 2026, 03:37:41 pm]
Unleashed Pascal (async/a...
by
chamfay
[August 15, 2026, 10:35:09 am]
TDWEdit
by
docno
[August 15, 2026, 10:12:10 am]
var vs out (including "co...
by
440bx
[August 15, 2026, 08:42:28 am]
Local AI LLM Wrapper Demo...
by
edwinyzh
[August 15, 2026, 05:30:15 am]
Trndi 16 is released
by
slicke
[August 15, 2026, 03:06:44 am]
Clean up and build
by
n7800
[August 14, 2026, 11:03:28 pm]
'ReadStr' ?
by
PascalDragon
[August 14, 2026, 08:33:34 pm]
Cross platform DirectoryW...
by
LemonParty
[August 14, 2026, 07:41:15 pm]
Lazarus Bugfix Release 4....
by
wp
[August 14, 2026, 04:47:58 pm]
Separators in the compone...
by
JuhaManninen
[August 14, 2026, 01:28:05 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Enumerating properties and methods of a class at runtime with RTTI (Read 358 times)
simsee
Full Member
Posts: 240
Enumerating properties and methods of a class at runtime with RTTI
«
on:
November 23, 2025, 07:50:29 pm »
I need to enumerate the properties and methods of a class at runtime. Is this already possible with classic RTTI, or do I need the extended RTTI, which is still under development? Thank you.
Logged
cdbc
Hero Member
Posts: 2929
Re: Enumerating properties and methods of a class at runtime with RTTI
«
Reply #1 on:
November 23, 2025, 08:39:02 pm »
Hi
If the class is compiled with
{$M+}
__and__ the properties and methods are
Published
, then yes, you can enumerate them with Classic RTTI.
Regards Benny
Logged
If it ain't broke, don't fix it
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release & FPC Main -> Lazarus Main
jamie
Hero Member
Posts: 7897
Re: Enumerating properties and methods of a class at runtime with RTTI
«
Reply #2 on:
November 23, 2025, 11:45:02 pm »
Code: Pascal
[Select]
[+]
[-]
unit
Unit1
;
{$mode objfpc}{$H+}
interface
uses
Classes
,
SysUtils
,
Forms
,
Controls
,
Graphics
,
Dialogs
,
StdCtrls
,
TypInfo
;
type
{ TForm1 }
TForm1
=
class
(
TForm
)
Button1
:
TButton
;
Memo1
:
TMemo
;
procedure
Button1Click
(
Sender
:
TObject
)
;
private
public
end
;
var
Form1
:
TForm1
;
implementation
{$R *.lfm}
{ TForm1 }
procedure
TForm1
.
Button1Click
(
Sender
:
TObject
)
;
Var
TheList
:
PPropList
=
Nil
;
I
,
J
:
Longint
;
S
:
string
;
begin
Memo1
.
Clear
;
J
:
=
GetPropList
(
Form1
,
TheList
)
;
For
I
:
=
0
to
J
-
1
do
begin
With
TheList
^
[
i
]
^
do
begin
WriteStr
(
S
,
'Property '
,
i
+
1
:
3
,
': '
,
name
:
30
)
;
Memo1
.
Lines
.
Add
(
S
)
;
writeStr
(
S
,
' Type: '
,
typinfo
.
PropType
(
form1
,
Name
)
)
;
Memo1
.
Lines
.
Add
(
S
)
;
end
;
end
;
Freemem
(
TheList
)
;
end
;
end
.
This works using FPC 3.2.2
Jamie
Logged
The only true wisdom is knowing you know nothing
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
LCL
»
Enumerating properties and methods of a class at runtime with RTTI
TinyPortal
© 2005-2018