输出属性类型为枚举类型

dengdeng 2000-03-20 02:34:00
加精
用MFC开发ActiveX控件,如何使控件的属性为枚举等自定义类型。
...全文
545 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
forgettor 2000-03-31
  • 打赏
  • 举报
回复
这个问题应当多给点分
solomon 2000-03-24
  • 打赏
  • 举报
回复
是直接修改.odl文件。
属性在old 是对外部程序而言的。属性页可以是任何类型,只要匹配byte
比如,枚举型 = int
Inspect 的树状显示好像是delphi 特有的,ocx 不支持。
dengdeng 2000-03-24
  • 打赏
  • 举报
回复
solomon,谢谢你的帮助。不过我现在还是有些迷糊。

能不能E我一个简单的控件(含属性页)包含枚举类型属性。

或者推荐基本书。
forgettor 2000-03-23
  • 打赏
  • 举报
回复
..
dengdeng 2000-03-23
  • 打赏
  • 举报
回复
请问solomon

在.odl中枚举类型的定义是怎样加进去的,直接修改.odl文件吗?还是有别的途径。

另外,如果我要做一个属性页,我怎样定义属性页中相应属性的类型,如何使属性

的显示和在DELPHI中的Inspect中的一样。
solomon 2000-03-22
  • 打赏
  • 举报
回复
请贴源代码,以及标示以下哪个地方要改成枚举类型
我改好后再贴上来
solomon 2000-03-21
  • 打赏
  • 举报
回复
程序中不必定义为枚举类型,只要是 int 形就可以了。
至于MFC模板?请贴源代码,以及标示以下哪个地方要改成枚举类型
dengdeng 2000-03-21
  • 打赏
  • 举报
回复
是这样。我要写一个串口通讯的控件,控件的属性中有串口的波特率、停止位等等。

我想在用户使用控件时,该属性显示的值为有意义的值。比如:停止位属性显示为

STOP_1。

可不可以说的详细些,最好再附上源代码。谢谢。
dengdeng 2000-03-20
  • 打赏
  • 举报
回复
如果我用MFC模板,又该如何?

程序中是否还要定义此枚举类型,我要对属性进行操作。
solomon 2000-03-20
  • 打赏
  • 举报
回复
把 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}}
};

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧