我做了一个activex 控件,想自定义一个结构通过接口参数传给控件,问如何来做??(问题解决马上给分) 我做了一个activex 控件,想自定义一个结构通过接口参数传给控件,问如何来做??(问题解决马上给分) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import "oaidl.idl";import "ocidl.idl"; typedef [uuid(D8B3861A-74C6-11d2-A0D6-00C04FB17CDB)] struct StudentStruct { VARIANT_BOOL graduate; short grade; BSTR name; }StudentStruct; [ object, uuid(D9C28B00-2D5E-4D2A-885F-DBB7F7DA98E3), dual, helpstring("ITran Interface"), pointer_default(unique) ] interface ITran : IDispatch { [propput, id(1), helpstring("property Zero")] HRESULT Zero([in] long newVal); [propget, id(2), helpstring("property ID")] HRESULT ID([out, retval] long *pVal); [propput, id(2), helpstring("property ID")] HRESULT ID([in] long newVal); [id(3), helpstring("method GetStudent")] HRESULT GetStudent([in, out]StudentStruct* pst); [id(4), helpstring("method GetStringArray")] HRESULT GetStringArray([in, out] SAFEARRAY(BSTR) *psa); };[ uuid(AB783E87-C2D7-4DB8-B6A3-45EDEE0F8EBF), version(1.0), helpstring("Trans 1.0 Type Library")]library TRANSLib{ importlib("stdole32.tlb"); importlib("stdole2.tlb"); [ uuid(34F5E700-2758-4C94-A2A3-616E6DC372BA), helpstring("_ITranEvents Interface") ] dispinterface _ITranEvents { properties: methods: [id(1), helpstring("method ZeroChanged")] HRESULT ZeroChanged(long psid, VARIANT *psa); }; [ uuid(449AC010-5024-4BDD-891B-AB0CBB0EB827), helpstring("Tran Class") ] coclass Tran { [default] interface ITran; [default, source] dispinterface _ITranEvents; };}; 我在我的odl文件中加入了import "oaidl.idl";import "ocidl.idl"; typedef [uuid(D8B3861A-74C6-11d2-A0D6-00C04FB17CDB)] struct StudentStruct { VARIANT_BOOL graduate; short grade; BSTR name; }StudentStruct;可是编译出错statements outside library block are illegal in mktyplib compatability mode : [ ]这该如何解决? to wei97081116(韦小宝) 你是在idl 文件中添加的上述代码吗?idl文件我为什我找不着(路径下没有)?我用com/ole object viewer 可以浏览但不能更改。如果不是在idl中添加的,我应该把它加在那? typedef [uuid(D8B3861A-74C6-11d2-A0D6-00C04FB17CDB)] struct StudentStruct { VARIANT_BOOL graduate; short grade; BSTR name; }StudentStruct; 你看看这篇文章http://comcamp.myrice.com/techarticles/com/0007.htm 我的控件是用Class wizard做的,还是有问题,在BEGIN_DISPATCH_MAP(CStructreturnCtrl, COleControl) //{{AFX_DISPATCH_MAP(CStructreturnCtrl) DISP_FUNCTION(CStructreturnCtrl, "GetInfofromocx", etInfofromocx, StudentStruct, VTS_BOOL) //}}AFX_DISPATCH_MAP DISP_FUNCTION_ID(CStructreturnCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)END_DISPATCH_MAP() 我无法处理以下语句 DISP_FUNCTION(CStructreturnCtrl, "GetInfofromocx", etInfofromocx, StudentStruct, VTS_BOOL)有问题?? 各位重绘高手,超级难题来了,有图有解释 串口通讯的一个问题 请问vc怎么操作excel啊? CreateJobObject调用时,编译错误,通知没有定义error C2065------参与有分 简单概念问题请教 MFC怎样使用BasicExcel类呀?求教? 一个简单问题:请问如何知道计算机中装的openGL版本?以及如何下载安装最新的openGL版本? 控件拦哪去了!(急) 那位大虾知道怎样求nt 或 win2000的数据流量,类似win2000中的那个东西 虚函数的问题 关于菜单的简单问题 请问Combo box怎么样才能把内容用下拉条全显示出来?谢谢
import "oaidl.idl";
import "ocidl.idl";
typedef
[uuid(D8B3861A-74C6-11d2-A0D6-00C04FB17CDB)]
struct StudentStruct
{
VARIANT_BOOL graduate;
short grade;
BSTR name;
}StudentStruct; [
object,
uuid(D9C28B00-2D5E-4D2A-885F-DBB7F7DA98E3),
dual,
helpstring("ITran Interface"),
pointer_default(unique)
]
interface ITran : IDispatch
{
[propput, id(1), helpstring("property Zero")] HRESULT Zero([in] long newVal);
[propget, id(2), helpstring("property ID")] HRESULT ID([out, retval] long *pVal);
[propput, id(2), helpstring("property ID")] HRESULT ID([in] long newVal);
[id(3), helpstring("method GetStudent")] HRESULT GetStudent([in, out]StudentStruct* pst);
[id(4), helpstring("method GetStringArray")] HRESULT GetStringArray([in, out] SAFEARRAY(BSTR) *psa);
};[
uuid(AB783E87-C2D7-4DB8-B6A3-45EDEE0F8EBF),
version(1.0),
helpstring("Trans 1.0 Type Library")
]
library TRANSLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb"); [
uuid(34F5E700-2758-4C94-A2A3-616E6DC372BA),
helpstring("_ITranEvents Interface")
]
dispinterface _ITranEvents
{
properties:
methods:
[id(1), helpstring("method ZeroChanged")] HRESULT ZeroChanged(long psid, VARIANT *psa);
}; [
uuid(449AC010-5024-4BDD-891B-AB0CBB0EB827),
helpstring("Tran Class")
]
coclass Tran
{
[default] interface ITran;
[default, source] dispinterface _ITranEvents;
};
};
import "oaidl.idl";
import "ocidl.idl";
typedef
[uuid(D8B3861A-74C6-11d2-A0D6-00C04FB17CDB)]
struct StudentStruct
{
VARIANT_BOOL graduate;
short grade;
BSTR name;
}StudentStruct;
可是编译出错
statements outside library block are illegal in mktyplib compatability mode : [ ]
这该如何解决?
[uuid(D8B3861A-74C6-11d2-A0D6-00C04FB17CDB)]
struct StudentStruct
{
VARIANT_BOOL graduate;
short grade;
BSTR name;
}StudentStruct;
http://comcamp.myrice.com/techarticles/com/0007.htm
BEGIN_DISPATCH_MAP(CStructreturnCtrl, COleControl)
//{{AFX_DISPATCH_MAP(CStructreturnCtrl)
DISP_FUNCTION(CStructreturnCtrl, "GetInfofromocx", etInfofromocx, StudentStruct, VTS_BOOL)
//}}AFX_DISPATCH_MAP
DISP_FUNCTION_ID(CStructreturnCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()
我无法处理以下语句
DISP_FUNCTION(CStructreturnCtrl, "GetInfofromocx", etInfofromocx, StudentStruct, VTS_BOOL)有问题??