Solved

Getting properties with typinfo.pas

Posted on 1998-04-23
4
505 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

730 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