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
Questions about TFuncSeri...
by
wp
[
Today
at 03:05:31 pm]
Getting results from sql ...
by
eny
[
Today
at 02:59:54 pm]
could Ardour's YTK be use...
by
fifr
[
Today
at 02:34:39 pm]
declaring Array
by
Thaddy
[
Today
at 01:24:11 pm]
Hello! Anything new?
by
marcov
[
Today
at 01:22:19 pm]
GTK3 : Icons have borders...
by
Schmitty2005
[
Today
at 01:02:16 pm]
Problem with drawing orde...
by
wp
[
Today
at 11:32:56 am]
TChart: Wrong default val...
by
wp
[
Today
at 11:30:54 am]
Text Fill (Memo)
by
paweld
[
Today
at 09:09:13 am]
Qt6/Wayland clipboard: pa...
by
AlexTP
[
Today
at 08:56:58 am]
Pocketbase
by
PierceNg
[
Today
at 06:29:04 am]
ADUG Symposium 2026
by
Mathias Burbach
[
Today
at 04:45:57 am]
Any way to "embed" Window...
by
jamie
[
Today
at 12:55:37 am]
CryptoLib4Pascal
by
Xor-el
[
Today
at 12:39:35 am]
CONCAT formula
by
veb86
[March 13, 2026, 05:20:42 pm]
DataPort StopBits and Flo...
by
Thaddy
[March 13, 2026, 02:14:16 pm]
Lazarus Bugfix Release 4....
by
JuhaManninen
[March 13, 2026, 10:05:03 am]
88 year D. Knuth changes ...
by
Thaddy
[March 13, 2026, 07:31:38 am]
interface and GUID someth...
by
egsuh
[March 13, 2026, 03:31:00 am]
CADSys4 3D.
by
maurog
[March 13, 2026, 01:00:05 am]
UOS - pre-compiled librar...
by
Fred vS
[March 13, 2026, 12:34:06 am]
Pipewire API
by
Fred vS
[March 12, 2026, 10:11:02 pm]
TSplitter color property ...
by
valdir.marcos
[March 12, 2026, 09:20:11 pm]
ShortStrings vs long stri...
by
valdir.marcos
[March 12, 2026, 08:55:02 pm]
LazPaint (alpha-blending,...
by
CM630
[March 12, 2026, 08:38:30 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Enumerating properties and methods of a class at runtime with RTTI (Read 316 times)
simsee
Full Member
Posts: 235
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: 2685
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: 7602
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