Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2005

Tip: Looking for answers? Try searching our database.

How to declare enum using attribute in VC++ .Net?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Woon Kiat  Wong - 18 Aug 2005 06:50 GMT
Hi,

Using IDL, I can declare my enumeration like following,

library MyAppLib
{
       importlib("stdole32.tlb");
       importlib("stdole2.tlb");

       typedef enum MyColor
       {
               ORANGE = 1,
               RED = 2
       } MyColor;

}

COM compatible client like VB can use the enum from their application
when import this library. How can I achieve the same thing in Visual
C++ .Net using attribute? I have tried [export] and [v1_enum], but the
enum is only exported to IDL like following

typedef enum MyColor
{
       ORANGE = 1,
       RED = 2

} MyColor;

library MyAppLib
{
       importlib("stdole32.tlb");
       importlib("stdole2.tlb");

       ........

}

I need the enum to be in the library section. Anyone knows how to solve
this?

regards,
Woon Kiat
Rodrigo Corral [MVP] - 18 Aug 2005 08:55 GMT
Here you have an example. This code is working for me in and ATL Attributed
project.
Tell us if it works or not.

[
export,
uuid("CCA6D17A-17F9-47d2-86AD-DB64B273B5C1"),
helpstring("MsgType"),
library_block
]
enum eMsgType
{
mtA = 1,
mtB = 2,
mtC = 3,
mtD = 4
}

Signature

Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org

Woon Kiat - 18 Aug 2005 09:05 GMT
Thank you, it's working!
Rodrigo Corral [MVP] - 11 Sep 2005 00:23 GMT
I´m glad to hear this.

Signature

Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.