Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exposing enumerations

Status
Not open for further replies.

azwaan

Programmer
Jan 11, 2002
42
0
0
Im involved in maintaining a already developed application of which a major
component is written in VC++. i have a requirement to add a global
enumeration to the component. so that it maybe exposed to the VB application
tht is using the DLL.

currently global enumerations have been defined in globalenums.h ( i have
also noticed that for each enumeration defined , there is also a entry in
the globlenums.idl) . however only some of the enumerations defined are
available in the VB side. i could not find any entries in the source files
that made it possible for some enumeration to be available in VB and for
some not to. ie.. both types of enumerations contains exectly the same kind
of entries in the source files.

coming back to my requiement , i need to add a new enumeration that will be
used in VB to the VC component. i have defined my enumeration by directly
editing the globalenums.h. however this did not achieve the desired result.

is there a way to add enumerations in the VC IDE thru menu options? how can
i expose this enumerations the way i want.

my sample code in globalenums.H is as follows

typedef /* [helpstring][v1_enum] */
enum StatusLevels
{
eStatusNone = 0,
eStatusInProgress = 1,
eStatusSuccess = 2,
eStatusFailed = 3
}
StatusLevels;

excuse but im pretty new to VC++.. this might really be a simple/stupid
question.

Thanx in advance

 
I suppose enums are compilation stage constant definitions and can not be exported in linking stage, because they simply allready does not exist at that stage. They are not global symbols like variables or function names. When you say enums are visible from VB side may be you mean that you can see variables (accepting values of enumerations)?
 
when i say that some enums are visible to the VB side i mean.. that when u reference the C++ Dll in VB, u can actually see the enumerations and its constant values in the VB object browser.

this also means that within VB Code , i can use the enumeration members as a replacement for the values it contains.

for example..if the following is defined in C++

enum DayOfWeek
{
Sunday=7
Monday=1
TuesDay=2
...
}
DayOfweek;

i can use a statment such as the following in VB.

today=Monday (instead of today=1)

the problem is some of the Enums defined in C++ seems to be available, and some are not for some inexplicable reason.

 
Are they not parallel defined somewhere in VB environment?
 
no they are not.. if u just open a new project in VB and reference the DLL.. these enumerations become available.
 
You are mentioned .idl files, they are for interface definition. Thats definitelly is the place where VB gets enum constant names. I'm totally infamilar with interfaces, have only heard that they must be compiled (MIDL) and registered in system registry.
 
yes i have used the MIDL compiler with the IDL file to generate the gloabalenums.H file. however when i build the dll the tlb file shows only some of the enumerations when opened using OLEview.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top