[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Getting properties with typinfo.pas

Posted on 1998-04-23
4
Medium Priority
?
516 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

656 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