如何添加集合属性
编号:QA003187
建立日期: 2000年7月20日 最后修改日期:2000年7月24日
所属类别:
Ace:
操作系统: Win9x
编程工具: VC++6
问题: 我在制作一个ActiveX控件,控件可以让一些高级语言(VB)能访问VxD的功能。希望控件的一个属性在其他支持ActiveX技术的语言中(VB),可以从一个集合中选择一个值,这个集合是在控件要修改属性(属性有'...'按钮)时,会出现下拉框提供可选项。具体怎么写?希望能告知各种不同类型值的例子。
水平: 一无所知
回答:
你需要修改.ODL或.IDL文件。在文件开始importlib(STDTYPE_TLB)的下面添加:
typedef enum tagLineStyleConstants
{
[helpstring("Solid")] lsSolid = 0,
[helpstring("Dash")] lsDash = 1,
[helpstring("Dot")] lsDot = 2,
[helpstring("Dash-Dot")] lsDashDot = 3,
[helpstring("Dash-Dot-Dot")] lsDashDotDot = 4,
} LineStyleConstants;
这是定义了一个枚举属性,在VB中会自动显示这些值供用户选择。然后修改属性的类型,如:
// NOTE - ClassWizard will maintain property information here.
// Use extreme caution when editing this section.
//{{AFX_ODL_PROP(CEnumTestCtrl)
[id(1)] LineStyleConstants LineStyle;
//}}AFX_ODL_PROP
相关问题:
QA003197 "怎么实现动态加载属性的可选项"
此问题由李海回答。
| |
|
|
| |
|
|