关于ActiveX 中属性的数据类型问题

sailingcelery 2003-08-19 04:05:11
关于ActiveX 中属性的数据类型问题

我在用VC做ActiveX控件中遇到这样的问题,
1.我无法用enum定义的类型来作为属性的数据类型。是不是就是不可以?

2.BOOL型的属性,在使用这个控件时,可以在控件的【Properties】中的【ALL】选 单中看到你可以通过下来列表来选择属性为True或者False 。
那我想如何让别的类型属性也可以有这个选择?
是不是需要用enum来定义属性的数据类型?还时如何做?
我看到有一个做好的OCX时这样的,可是我没有他的源代码无法知道如何做的。

...全文
160 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sailingcelery 2003-08-22
  • 打赏
  • 举报
回复
下面是我的源文件。Link_Def 是我程序中定义的Enum
// AdapterIVROcx.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 (AdapterIVROcx.tlb) that will become a resource in
// AdapterIVROcx.ocx.

#include <olectl.h>
#include <idispids.h>

[ uuid(D3083293-4B2C-4D37-868F-D8D42335ACBD), version(1.0),
helpfile("AdapterIVROcx.hlp"),
helpstring("AdapterIVROcx ActiveX Control module"),
control ]
library ADAPTERIVROCXLib
{
importlib(STDOLE_TLB);
importlib(STDTYPE_TLB);

// Primary dispatch interface for CAdapterIVROcxCtrl

[ uuid(6CEBC505-092A-4F88-AAC9-43E2E9E336BC),
helpstring("Dispatch interface for AdapterIVROcx Control"), hidden ]
dispinterface _DAdapterIVROcx
{
properties:
// NOTE - ClassWizard will maintain property information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_PROP(CAdapterIVROcxCtrl)
[id(1)] BSTR SIP;
[id(2)] short PortCount;
[id(3)] short PBXType;
[id(4)] boolean isLog;
[id(5)] short SocketPort;
[id(6)] short Mode;
[id(7)] short APIVer;
[id(8)] BSTR UEIData;
[id(9)] short UEILen;
[id(10)] BSTR AgentID;
[id(11)] BSTR AgentData;
[id(12)] BSTR AgentGroup;
[id(13)] BSTR deviceDN;
[id(14)] short deviceType;
[id(15)] BSTR NetType;
[id(16)] boolean isUseThread;
[id(18)] short DelayTime;
[id(17)] boolean IsIVR;
//}}AFX_ODL_PROP

methods:
// NOTE - ClassWizard will maintain method information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_METHOD(CAdapterIVROcxCtrl)
[id(19)] short Start();
[id(20)] short Stop();
[id(21)] short spAnswer();
[id(22)] short spMakeCall(BSTR TargetDN);
[id(23)] short spSingleStepTransfer(BSTR SourceDN, BSTR TargetDN);
[id(24)] short InitIVRInfo(BSTR sFileName);
//}}AFX_ODL_METHOD

[id(DISPID_ABOUTBOX)] void AboutBox();
};

// Event dispatch interface for CAdapterIVROcxCtrl

[ uuid(5287DBA4-4447-4609-B339-C55FFC1193FB),
helpstring("Event interface for AdapterIVROcx Control") ]
dispinterface _DAdapterIVROcxEvents
{
properties:
// Event interface has no properties

methods:
// NOTE - ClassWizard will maintain event information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_EVENT(CAdapterIVROcxCtrl)
[id(1)] void GetEvent(long result, long eventKind);
//}}AFX_ODL_EVENT
};

// Class information for CAdapterIVROcxCtrl

[ uuid(80A2B6F8-0622-4332-A950-97BF25BDDE94),
helpstring("AdapterIVROcx Control"), control ]
coclass AdapterIVROcx
{
[default] dispinterface _DAdapterIVROcx;
[default, source] dispinterface _DAdapterIVROcxEvents;
};

[ uuid(708B6921-621B-11d3-9285-0080ADB811C5) ]
typedef enum Link_Def
{
Shape_rectangle = 0,Shape_roundrect,Shape_ellipse
} Link_Def;
//{{AFX_APPEND_ODL}}
//}}AFX_APPEND_ODL}}
};
sailingcelery 2003-08-22
  • 打赏
  • 举报
回复
我测试了。可是在我【Ctrl + W】时就告诉我kAppearanceEnum不是一个OLE合法的数据类型呀。
sailingcelery 2003-08-22
  • 打赏
  • 举报
回复
谢谢你了。

不过我还是又一些疑问。

UUID就是直接自己生成么?怎么生成?自己编一个?

kAppearanceEnum就是我在程序里定义Enum的名字么?

其余的内容是不是不改变了?
macadamia 2003-08-19
  • 打赏
  • 举报
回复
以自定义对象的形状类型为例:

在.idl or .odl文件中,enum自定义的类型,其中uuid自己生成

typedef [uuid(708B6921-621B-11d3-9285-0080ADB811C5)]
enum kAppearanceEnum
{
Shape_rectangle = 0,Shape_roundrect,Shape_ellipse
} kAppearanceEnum;

然后,将相应的属性类型都改为kAppearanceEnum 就可以了
sailingcelery 2003-08-19
  • 打赏
  • 举报
回复
晕,还是没有人回答呀。
sailingcelery 2003-08-19
  • 打赏
  • 举报
回复
没有人回?郁闷呀。

急切等待中。。。。。。。

3,245

社区成员

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

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