BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

GetEnumName / TypeInfo and __typeinfo - not the same between

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Hiring in Vancouver BC
Guest





PostPosted: Wed Feb 28, 2007 3:08 am    Post subject: GetEnumName / TypeInfo and __typeinfo - not the same between Reply with quote



I have some Delphi code I need to port to C++ Builder. Should be easy right?
I have to find the enumeration name (string) of a specific enumeration
value, as in the following Delphi code:

btnTypeName := GetEnumName(TypeInfo(TMsgDlgBtn), integer(B));

// where B is set to a specific enum value in TMsgDlgButtons (like mbYes for
example).

OK - but TypeInfo is not the same in C++ Builder... So I would like to do
something like:

PPropInfo PropInfo = GetPropInfo(__typeinfo(TMsgDlgButtons), "TMsgDlgBtn");
const AnsiString btnTypeName = GetEnumName(*(PropInfo->PropType), int(i));

Which would work - EXCEPT - TMsgDlgButtons is not a VCL class (its a set<>).

How can I get the darn name of the enumeration value in C++ Builder?


TIA.
M
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Feb 28, 2007 3:40 am    Post subject: Re: GetEnumName / TypeInfo and __typeinfo - not the same bet Reply with quote



"Hiring in Vancouver BC" <nospam (AT) nospam (DOT) com> wrote in message
news:45e49dd4 (AT) newsgroups (DOT) borland.com...

Quote:
I have some Delphi code I need to port to C++ Builder. Should be
easy right?


No, because standalone enums don't have RTTI in C++ like they can in
Delphi. You have to fudge the compiler to generate usable RTTI. One
way is to declare a published property of the desired enum type in a
wrapper class. Then you can use GetEnumName() in C++. For example:

http://groups.google.com/group/borland.public.cppbuilder.vcl.components.using/msg/f03d3673a62c204c

Quote:
I have to find the enumeration name (string) of a specific
enumeration
value, as in the following Delphi code:

btnTypeName := GetEnumName(TypeInfo(TMsgDlgBtn), integer(B));

Using the code in the above posting, that would translate into the
following:

DECLARE_ENUM_TYPEINFO(TMsgDlgBtn)
...
btnTypeName = GetEnumName(GET_ENUM_TYPEINFO(TMsgDlgBtn), (int)B);

Quote:
PPropInfo PropInfo = GetPropInfo(__typeinfo(TMsgDlgButtons),
"TMsgDlgBtn");


You can't do that. Sets don't have properties of their own.


Gambit
Back to top
Jim Davis
Guest





PostPosted: Tue May 08, 2007 8:10 am    Post subject: Re: GetEnumName / TypeInfo and __typeinfo - not the same bet Reply with quote



Seeking GetEnumName for BCB 6 .
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Tue May 08, 2007 11:53 pm    Post subject: Re: GetEnumName / TypeInfo and __typeinfo - not the same bet Reply with quote

Jim Davis <jim46dd (AT) hotmail (DOT) com> wrote:

Quote:
Seeking GetEnumName for BCB 6 .

Please go to http://www.deja.com and search through the newsgroup archives. Examples of using GetEnumName() have been posted several times before.


Gambit
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.