您的位置:首页 > 其它

ATL ActiveX 控件的方法或事件中使用枚举常量

2008-02-18 09:29 495 查看
ATL ActiveX控件一般在方法(包括属性)和事件反馈中使用枚举常量。

可以在控件的IDL文件中编写代码,见彩色部分代码。

import "oaidl.idl";
import "ocidl.idl";
[
object,
uuid(A0A2E087-0A96-4861-BED2-549F9A0AC2C2),
dual,
nonextensible,
helpstring("IHLMessage Interface"),
pointer_default(unique)
]
interface IHLMessage : IDispatch{

//在方法中使用枚举

[id(1), helpstring("method A")] HRESULT A([in] enum HL_MSG_STYLE style);
[id(2), helpstring("method B")] HRESULT B([in] LONG i);
};
[
uuid(5181C89F-A37F-4632-8241-92F152A8D426),
version(1.0),
helpstring("ActiveX for HuaLong Message Component 1.0")
]
library HuaLongALib
{

importlib("stdole2.tlb");

//定义枚举
enum HL_MSG_STYLE
{
HL_MSG_INFOMATION = 0,
HL_MSG_ERROR = 1
} ;


[
uuid(D8EC72C0-6018-4572-88C2-AC9D2F3873AC),
helpstring("_IHLMessage Event Interface")
]
dispinterface _IHLMessageEvents
{
properties:
methods:

//在事件中使用枚举
[id(1), helpstring("Event OnA")] HRESULT OnA([in] enum HL_MSG_STYLE style);
};
[
uuid(414A7FDA-F1C4-438F-98D0-ABA598827D7F),
helpstring("HLMessage Class")
]
coclass HLMessage
{
[default] interface IHLMessage;
[default, source] dispinterface _IHLMessageEvents;
};
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐