?
Solved

Getting run time value of property of an object

Posted on 2005-04-29
3
Medium Priority
?
178 Views
Last Modified: 2010-04-05
So far, I've figured out how to generate a run time list of all the properties of an object, and what types they are, but I can't figure out how to get the actual value that the property is set to.

Here's the code I have so far.

//==================================================
procedure TComponentProperties.GetPropertyNameList(AObject: TObject;
  NameList: TStrings);
var
  i, PropCount : integer;
  PropList : PPropList;
  PropInfo : PPropInfo;
  TypeKinds : TTypeKinds;
  NewNameList : TStrings;

begin
  TypeKinds := [tkInteger, tkChar, tkEnumeration, tkFloat, tkString, tkSet, tkClass, tkWChar,
                tkLString, tkWString, tkVariant,  tkArray,  tkRecord,  tkInterface,  tkInt64, tkDynArray];

  PropCount := GetPropList(AObject, PropList);
  GetMem(PropList, PropCount * SizeOf(PPropInfo));
  try
    GetPropList(AObject.ClassInfo, TypeKinds, PropList);

    for I := 0 to PropCount - 1s do
      begin
      Try
      if PropList[i].PropType^.Kind = tkEnumeration then
       NameList.Add(FIndentString + PropList[i].Name + '=' + //CODE HERE TO DISPLAY VALUE OF PROPERTY);

That will produce a list of all the tkEnumeration property's...Any ideas on how to get the actual value of it?

Thanks
Kevin
0
Comment
Question by:kevinjd
  • 2
3 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 13895574
Hi,

Something like:

NameList.Add(FIndentString + PropList[i].Name + '=' + IntToStr(GetOrdProp((AObject as TComponent), PropInfo))); //CODE ...

Regards, Geo
0
 
LVL 17

Accepted Solution

by:
geobul earned 1000 total points
ID: 13895603
The last parameter was wrong. Try this way:

NameList.Add(FIndentString + PropList[i].Name + '=' + IntToStr(GetOrdProp((AObject as TComponent), PropList[i])));
0
 

Author Comment

by:kevinjd
ID: 13897056
Thank you. That worked nicely.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

839 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