Solved

Getting properties with typinfo.pas

Posted on 1998-04-23
4
498 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

746 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