VS2012 ActiveX控件_D接口添加方法事项

自己写的是Clock控件,所以控件的接口是_DClock

 

使用向导添加方法后,会在紫色区域自动生成红色代码:(添加Hello方法)

dispinterface _DClock
{
properties:
methods:
//void Hello(); //刚开始按照自己的思路,添加的方法,不正确
[id(1)] void Hello(void);//系统自动生成代码
};

 

coclass Clock
{
[default,[id] helpstring("method Hello")] dispinterface _DClock;
[default, source] dispinterface _DClockEvents;
};

但是编译不成功,有错误

 

1>.\Clock.idl(48): error MIDL2025: syntax error : expecting ] or , near "["
1>.\Clock.idl(48): error MIDL2025: syntax error : expecting ( near "]"
1>.\Clock.idl(48): error MIDL2316: illegal expression type used in attribute

 

删除 [id] 后,可编译成功,用TSTCON32.exe测试,正常。

 

posted @ 2014-03-07 11:36  侏小儒  阅读(364)  评论(0编辑  收藏  举报