| View previous topic :: View next topic |
| Author |
Message |
Hiring in Vancouver BC Guest
|
Posted: Wed Feb 28, 2007 3:08 am Post subject: GetEnumName / TypeInfo and __typeinfo - not the same between |
|
|
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
|
Posted: Wed Feb 28, 2007 3:40 am Post subject: Re: GetEnumName / TypeInfo and __typeinfo - not the same bet |
|
|
"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
|
Posted: Tue May 08, 2007 8:10 am Post subject: Re: GetEnumName / TypeInfo and __typeinfo - not the same bet |
|
|
Seeking GetEnumName for BCB 6 . |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue May 08, 2007 11:53 pm Post subject: Re: GetEnumName / TypeInfo and __typeinfo - not the same bet |
|
|
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 |
|
 |
|