473,326 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

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

Nov 17 '05 #1
3 1628
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
}
--
Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org
Nov 17 '05 #2
Thank you, it's working!

Nov 17 '05 #3
I´m glad to hear this.
--
Un saludo
Rodrigo Corral González [MVP]

FAQ de microsoft.public.es.vc++
http://rcorral.mvps.org
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Woon Kiat | last post by:
Hi, Using IDL, I can declare my enumeration like following, library MyAppLib { importlib("stdole32.tlb"); importlib("stdole2.tlb"); typedef enum MyColor
5
by: John Smith | last post by:
I have a custom enum to list comparison operators: =, <, <=, >, >= . I have created it as follows: public enum Comparator {Equal, LessThan, LessThanOrEqual,GreaterThan,GreaterThanOrEqual} Now...
21
by: Andreas Huber | last post by:
Hi there Spending half an hour searching through the archive I haven't found a rationale for the following behavior. using System; // note the missing Flags attribute enum Color {
10
by: Ken Allen | last post by:
The ToString() function, when applied to a variable that is an enumeration type, results in a string that is the name of the enumerated value that was defined in the source code. This is cool, but...
3
by: Sanjay Pais | last post by:
I know that string/char enum is not possible in c# (.NET2.0) I need to create the equivalent of this: public enum HOW_GOOD { AWESOME = "A", GREAT= "G", NOT_TOO_BAD = "N", TERRIBLE="T" }
5
by: Alan Cobb | last post by:
Hi, In the managed C++ class below I get compile warning C4677 from VS2003. "signature of non-private function contains assembly private type", even though the managed enum is public. I have...
6
by: Jason Larion | last post by:
When working with enums, I've noticed some behaviour that seems completely counter-intuitive to me. I was wondering if someone here could help restore my sanity, or at least help me to understand...
2
by: Ray Cassick \(Home\) | last post by:
I have a function that takes a value is as System.Enum and I want to be able to look at that value and determine if it is a regular enum or an enum that has a <Flag()> attribute set on it. I am...
34
by: Steven Nagy | last post by:
So I was needing some extra power from my enums and implemented the typesafe enum pattern. And it got me to thinking... why should I EVER use standard enums? There's now a nice little code...
6
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Suppose I have two enums which has an item with the same names -- but different values, enum foo { NAME = 100;
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.