Solved

Getting properties with typinfo.pas

Posted on 1998-04-23
4
502 Views
Last Modified: 2013-11-23
I have an object, of unknown type.  I want a list of the published property names.  To get the number of items, I use:

nProps := GetTypeData(MyObject.ClassInfo)^.PropCount;

I get each property name with:

  GetPropInfos(Source.ClassInfo,SourceProps);
  for PropNo := 0 to nProps-1 do begin
    PropertyName:= (SourceProps[PropNo])^.Name;

This works for all properties except record types (eg TRect).  They're just not included in the list, or the count of properties....

Any ideas?


0
Comment
Question by:bcrotaz
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
extreme earned 100 total points
ID: 1336754
That's because propinfo works only with the published properties of objects. And with properties that *can* be published, records, the same as other types, don't works with typeinfo. Try to put a record published, then register the component with Delphi and look in the object inspector. Doesn't works. If you need something that has fields you have to use a class, like TFont for example. If you need this for a record like TRect, build a class with the same fields of TRect and if you want you can add it some methods to give it more functionality.
0
 
LVL 1

Author Comment

by:bcrotaz
ID: 1336755
OK. That's disappointing.  I'll have to find a workaround.
I originally used a class - it's for a date-time type thing.
The class had the DateToStr etc methods.
I found I got access violations all over the place.
I'll look at how TFont is used.
0
 
LVL 1

Expert Comment

by:extreme
ID: 1336756
You can't use TDateTime for that? TDateTime is a floating point value, that is perfectly compatible with published properties and RTTI. Of course if you want to split it in fields you have to use a class.
0
 
LVL 1

Author Comment

by:bcrotaz
ID: 1336757
No - I need frames too.
I did it with a Longint.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now