Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to retrieve all string properties and their values from any TObject descenda Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
19-Oct-02
Category
Object Pascal
Language
Delphi 2.x
Views
148
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

How to retrieve all string properties and their values from any TObject descendant

Answer:

1   { ... }
2   var
3     XObject: TObject;
4     XProps: PPropList;
5     XPropInfo: PPropInfo;
6     XTypeData: PTypeData;
7     XPropsStr: string;
8     i: integer;
9     { ... }
10  begin
11    { ... }
12    XObject := OneOfYourComponents;
13    XTypeData := TypInfo.GetTypeData(XObject.ClassInfo);
14    XPropsStr := '';
15    GetMem(XProps, XTypeData^.PropCount * sizeof(Pointer));
16    try
17      TypInfo.GetPropInfos(XObject.ClassInfo, XProps);
18      for i := 0 to XTypeData.PropCount - 1 do
19      begin
20        XPropInfo := XProps[i];
21        if Assigned(XPropInfo) then
22        begin
23          if XPropInfo.PropType^^.Kind in [tkString, tkLString, tkWString] then
24            XPropsStr := XPropsStr + XProps[i].Name + ' = ' +
25              GetStrProp(XObject, XProps[i].Name) + #$0D#$0A;
26        end;
27      end;
28    finally
29      FreeMem(XProps);
30    end;
31    ShowMessage(XPropsStr);
32    { ... }


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC