把 enum 写到 typelib 定义文件中去
举例:(我自己编的控件代码)
// HoverButton.odl : type library source for ActiveX Control project.// This file will be processed by the Make Type Library (mktyplib) tool to
// produce the type library (HoverButton.tlb) that will become a resource in
// HoverButton.ocx.#include <olectl.h>
#include <idispids.h>[ uuid(A6B9C705-C1B5-11D2-AB5E-0000E82A9730), version(1.0),
helpfile("HoverButton.hlp"),
helpstring("HoverButton ActiveX Control module"),
control ]
library HOVERBUTTONLib
{
importlib(STDOLE_TLB);
importlib(STDTYPE_TLB); // Primary dispatch interface for CHoverButtonCtrl
typedef
[ uuid(CD470FA1-CB0F-11d2-AB5E-0000E82A9730),
helpstring("Dispatch interface for HoverButton Control Style") ]
enum tagBtnStyle
{
[helpstring("Simple")] BS_NONE = 0,
[helpstring("Flat Button")] BS_FLAT = 1,
[helpstring("Spot Light")] BS_SPOT = 2,
}BTNSTYLE; [ uuid(A6B9C706-C1B5-11D2-AB5E-0000E82A9730),
helpstring("Dispatch interface for HoverButton Control"), hidden ]
dispinterface _DHoverButton
{
properties:
// NOTE - ClassWizard will maintain property information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_PROP(CHoverButtonCtrl)
[id(DISPID_CAPTION), bindable, requestedit] BSTR Caption;
[id(DISPID_FONT), bindable] IFontDisp* Font;
[id(DISPID_BACKCOLOR), bindable, requestedit] OLE_COLOR BackColor;
[id(DISPID_FORECOLOR), bindable, requestedit] OLE_COLOR ForeColor;
[id(3)] IPictureDisp* Picture;
[id(1)] OLE_COLOR SpotBackColor;
[id(2)] OLE_COLOR SpotForeColor;
[id(4)] BTNSTYLE Style;
//}}AFX_ODL_PROP methods:
// NOTE - ClassWizard will maintain method information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_METHOD(CHoverButtonCtrl)
//}}AFX_ODL_METHOD [id(DISPID_ABOUTBOX)] void AboutBox();
}; // Event dispatch interface for CHoverButtonCtrl [ uuid(A6B9C707-C1B5-11D2-AB5E-0000E82A9730),
helpstring("Event interface for HoverButton Control") ]
dispinterface _DHoverButtonEvents
{
properties:
// Event interface has no properties methods:
// NOTE - ClassWizard will maintain event information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_EVENT(CHoverButtonCtrl)
[id(DISPID_CLICK)] void Click();
[id(DISPID_DBLCLICK)] void DblClick();
//}}AFX_ODL_EVENT
}; // Class information for CHoverButtonCtrl [ uuid(A6B9C708-C1B5-11D2-AB5E-0000E82A9730),
helpstring("HoverButton Control"), control ]
coclass HoverButton
{
[default] dispinterface _DHoverButton;
[default, source] dispinterface _DHoverButtonEvents;
};
//{{AFX_APPEND_ODL}}
//}}AFX_APPEND_ODL}}
};
举例:(我自己编的控件代码)
// HoverButton.odl : type library source for ActiveX Control project.// This file will be processed by the Make Type Library (mktyplib) tool to
// produce the type library (HoverButton.tlb) that will become a resource in
// HoverButton.ocx.#include <olectl.h>
#include <idispids.h>[ uuid(A6B9C705-C1B5-11D2-AB5E-0000E82A9730), version(1.0),
helpfile("HoverButton.hlp"),
helpstring("HoverButton ActiveX Control module"),
control ]
library HOVERBUTTONLib
{
importlib(STDOLE_TLB);
importlib(STDTYPE_TLB); // Primary dispatch interface for CHoverButtonCtrl
typedef
[ uuid(CD470FA1-CB0F-11d2-AB5E-0000E82A9730),
helpstring("Dispatch interface for HoverButton Control Style") ]
enum tagBtnStyle
{
[helpstring("Simple")] BS_NONE = 0,
[helpstring("Flat Button")] BS_FLAT = 1,
[helpstring("Spot Light")] BS_SPOT = 2,
}BTNSTYLE; [ uuid(A6B9C706-C1B5-11D2-AB5E-0000E82A9730),
helpstring("Dispatch interface for HoverButton Control"), hidden ]
dispinterface _DHoverButton
{
properties:
// NOTE - ClassWizard will maintain property information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_PROP(CHoverButtonCtrl)
[id(DISPID_CAPTION), bindable, requestedit] BSTR Caption;
[id(DISPID_FONT), bindable] IFontDisp* Font;
[id(DISPID_BACKCOLOR), bindable, requestedit] OLE_COLOR BackColor;
[id(DISPID_FORECOLOR), bindable, requestedit] OLE_COLOR ForeColor;
[id(3)] IPictureDisp* Picture;
[id(1)] OLE_COLOR SpotBackColor;
[id(2)] OLE_COLOR SpotForeColor;
[id(4)] BTNSTYLE Style;
//}}AFX_ODL_PROP methods:
// NOTE - ClassWizard will maintain method information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_METHOD(CHoverButtonCtrl)
//}}AFX_ODL_METHOD [id(DISPID_ABOUTBOX)] void AboutBox();
}; // Event dispatch interface for CHoverButtonCtrl [ uuid(A6B9C707-C1B5-11D2-AB5E-0000E82A9730),
helpstring("Event interface for HoverButton Control") ]
dispinterface _DHoverButtonEvents
{
properties:
// Event interface has no properties methods:
// NOTE - ClassWizard will maintain event information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_EVENT(CHoverButtonCtrl)
[id(DISPID_CLICK)] void Click();
[id(DISPID_DBLCLICK)] void DblClick();
//}}AFX_ODL_EVENT
}; // Class information for CHoverButtonCtrl [ uuid(A6B9C708-C1B5-11D2-AB5E-0000E82A9730),
helpstring("HoverButton Control"), control ]
coclass HoverButton
{
[default] dispinterface _DHoverButton;
[default, source] dispinterface _DHoverButtonEvents;
};
//{{AFX_APPEND_ODL}}
//}}AFX_APPEND_ODL}}
};
至于MFC模板?请贴源代码,以及标示以下哪个地方要改成枚举类型
属性在old 是对外部程序而言的。属性页可以是任何类型,只要匹配byte
比如,枚举型 = int
Inspect 的树状显示好像是delphi 特有的,ocx 不支持。