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 use RTTI to determine if a property is a TDateTime 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
23-Oct-03
Category
Object Pascal
Language
Delphi 4.x
Views
174
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Lou Adler

How to use RTTI to determine if a property is a TDateTime 

Answer:

When it comes to RTTI, TDateTime and Double are not the same. That's what the extra 
"type" keyword in TDateTime's declaration is for: to give it its own RTTI, distinct 
from that of Double. Here is an example:

1   program Test;
2   
3   uses
4     TypInfo;
5   
6   {$APPTYPE CONSOLE}
7   {$M+}
8   type
9     TTest = class
10    private
11      FDateTime: TDateTime;
12    published
13      property D: TDateTime read FDateTime write FDateTime;
14    end;
15  
16  var
17    T: TTest;
18    DateInfo: Pointer;
19    TestInfo: PPropInfo;
20  begin
21    T := TTest.Create;
22    DateInfo := TypeInfo(TDateTime);
23    TestInfo := GetPropInfo(T, 'D');
24    writeln(DateInfo = TestInfo^.PropType^);
25    readln;
26  end.


It should print TRUE on the console.


			
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