王朝百科
分享
 
 
 

InvokeHelper

王朝百科·作者佚名  2010-07-29  
宽屏版  字体: |||超大  

当在项目中插入ActiveX控件ClassWizard生成的CWnd的派生类C++类中,可以看到其成员函数的代码中都有对InvokeHelper函数的调用,InvokeHelper函数的第一个参数都和对应的属性或方法在ActiveX控件中的分发(dispatch)ID(标识ActiveX控件的方法或属性的)相对应。通过查看ActiveX控件hlp文件可以发现,ActiveX控件的方法在生存的C++类中都有同名的成员函数与之对应,ActiveX控件的属性都有一组Get和Set函数对其操作,其中ActiveX控件的方法和属性操作与生成的C++类成员函数相关联都是通过InvokeHelper函数的调用来完成的,InvokeHelper函数的第一个参数是由Component Gallery(控件提供者)提供的。因为经过这样的处理,所以我们如果要调用ActiveX控件的方法或对其属性进行取和设置操作,只需调用生成的C++类对应的成员函数便可。

下面对InvokeHelper单独说明:

CWnd::InvokeHelper

void InvokeHelper( DISPID dwDispID, WORD wFlags, VARTYPE vtRet, void* pvRet, const BYTE* pbParamInfo, ... );

说明:

Call this member function to invoke the OLE control method or property specified by dwDispID, in the context specified by wFlags.

其中参数:

dwDispID:

//Identifies the method or property to be invoked. This value is usually supplied by Component Gallery.

wFlags:可以为下面些值,指明调用InvokeHelper的目的。

//[ DISPATCH_METHOD ] The member is invoked as a method. If a property has the same name, both this and the DISPATCH_PROPERTYGET flag may be set.

[ DISPATCH_PROPERTYGET ] The member is retrieved as a property or data member.

[ DISPATCH_PROPERTYPUT ] The member is changed as a property or data member.

[ DISPATCH_PROPERTYPUTREF ] The member is changed by a reference assignment, rather than a value assignment. This flag is valid only when the property accepts a reference to an object.

vtRet:

//Specifies the type of the return value.

VT_EMPTY void

VT_I2 short

VT_I4 long

VT_R4 float

VT_R8 double

VT_CY CY

VT_DATE DATE

VT_BSTR BSTR

VT_DISPATCH LPDISPATCH

VT_ERROR SCODE

VT_BOOL BOOL

VT_VARIANT VARIANT

VT_UNKNOWN LPUNKNOWN

pvRet:

//Address of the variable that will that will receive the property value or return value. It must match the type specified by vtRet.

pbParamInfo:一般都设置为NULL

//Pointer to a null-terminated string of bytes specifying the types of the parameters following pbParamInfo.

specifies the types of the parameters passed to the method or property.

...:

//Variable List of parameters, of types specified in pbParamInfo.

InvokeHelper()函数的用法

1、播放文件的函数:

void CActiveMovie3::Run()

{

InvokeHelper(0x60020001, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);

}

2、暂停播放的函数: void CActiveMovie3::Pause()

{

InvokeHelper(0x60020002, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);

}

4、停止播放的函数: void CActiveMovie3::Stop()

{

InvokeHelper(0x60020003, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);

}

5、获得文件的函数: CString CActiveMovie3::GetFileName()

{

CString result;

InvokeHelper(0xb, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);

return result;

}

6、设置文件的函数: void CActiveMovie3::SetFileName(LPCTSTR lpszNewValue)

{

static BYTE parms[] = VTS_BSTR;

InvokeHelper(0xb, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,

lpszNewValue);

}

7、获得播放位置的函数: double CActiveMovie3::GetCurrentPosition()

{

double result;

InvokeHelper(0xd, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, NULL);

return result;

}

8、设置播放位置的函数: void CActiveMovie3::SetCurrentPosition(double newValue)

{

static BYTE parms[] = VTS_R8;

InvokeHelper(0xd, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);

}

9、获得音量的函数: long CActiveMovie3::GetVolume()

{

long result;

InvokeHelper(0x13, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);

return result;

}

10、设置音量的函数: void CActiveMovie3::SetVolume(long nNewValue)

{

static BYTE parms[] = VTS_I4;

InvokeHelper(0x13, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, nNewValue);

} 当在项目中插入ActiveX控件ClassWizard生成的CWnd的派生类C++类中,可以看到其成员函数的代码中都有对InvokeHelper函数的调用,InvokeHelper函数的第一个参数都和对应的属性或方法在ActiveX控件中的分发(dispatch)ID(标识ActiveX控件的方法或属性的)相对应。通过查看ActiveX控件hlp文件可以发现,ActiveX控件的方法在生存的C++类中都有同名的成员函数与之对应,ActiveX控件的属性都有一组Get和Set函数对其操作,其中ActiveX控件的方法和属性操作与生成的C++类成员函数相关联都是通过InvokeHelper函数的调用来完成的,InvokeHelper函数的第一个参数是由Component Gallery(控件提供者)提供的。因为经过这样的处理,所以我们如果要调用ActiveX控件的方法或对其属性进行取和设置操作,只需调用生成的C++类对应的成员函数便可。

下面对InvokeHelper单独说明:

CWnd::InvokeHelper

void InvokeHelper( DISPID dwDispID, WORD wFlags, VARTYPE vtRet, void* pvRet, const BYTE* pbParamInfo, ... );

说明:

Call this member function to invoke the OLE control method or property specified by dwDispID, in the context specified by wFlags.

其中参数:

dwDispID:

//Identifies the method or property to be invoked. This value is usually supplied by Component Gallery.

wFlags:可以为下面些值,指明调用InvokeHelper的目的。

//[ DISPATCH_METHOD ] The member is invoked as a method. If a property has the same name, both this and the DISPATCH_PROPERTYGET flag may be set.

[ DISPATCH_PROPERTYGET ] The member is retrieved as a property or data member.

[ DISPATCH_PROPERTYPUT ] The member is changed as a property or data member.

[ DISPATCH_PROPERTYPUTREF ] The member is changed by a reference assignment, rather than a value assignment. This flag is valid only when the property accepts a reference to an object.

vtRet:

//Specifies the type of the return value.

VT_EMPTY void

VT_I2 short

VT_I4 long

VT_R4 float

VT_R8 double

VT_CY CY

VT_DATE DATE

VT_BSTR BSTR

VT_DISPATCH LPDISPATCH

VT_ERROR SCODE

VT_BOOL BOOL

VT_VARIANT VARIANT

VT_UNKNOWN LPUNKNOWN

pvRet:

//Address of the variable that will that will receive the property value or return value. It must match the type specified by vtRet.

pbParamInfo:一般都设置为NULL

//Pointer to a null-terminated string of bytes specifying the types of the parameters following pbParamInfo.

specifies the types of the parameters passed to the method or property.

...:

//Variable List of parameters, of types specified in pbParamInfo.

 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
如何用java替换看不见的字符比如零宽空格​十六进制U+200B
 干货   2023-09-10
网页字号不能单数吗,网页字体大小为什么一般都是偶数
 干货   2023-09-06
java.lang.ArrayIndexOutOfBoundsException: 4096
 干货   2023-09-06
Noto Sans CJK SC字体下载地址
 干货   2023-08-30
window.navigator和navigator的区别是什么?
 干货   2023-08-23
js获取referer、useragent、浏览器语言
 干货   2023-08-23
oscache遇到404时会不会缓存?
 干货   2023-08-23
linux下用rm -rf *删除大量文件太慢怎么解决?
 干货   2023-08-08
刀郎新歌破世界纪录!
 娱乐   2023-08-01
js实现放大缩小页面
 干货   2023-07-31
生成式人工智能服务管理暂行办法
 百态   2023-07-31
英语学习:过去完成时The Past Perfect Tense举例说明
 干货   2023-07-31
Mysql常用sql命令语句整理
 干货   2023-07-30
科学家复活了46000年前的虫子
 探索   2023-07-29
英语学习:过去进行时The Past Continuous Tense举例说明
 干货   2023-07-28
meta name="applicable-device"告知页面适合哪种终端设备:PC端、移动端还是自适应
 干货   2023-07-28
只用css如何实现打字机特效?
 百态   2023-07-15
css怎么实现上下滚动
 干货   2023-06-28
canvas怎么画一个三角形?
 干货   2023-06-28
canvas怎么画一个椭圆形?
 干货   2023-06-28
canvas怎么画一个圆形?
 干货   2023-06-28
canvas怎么画一个正方形?
 干货   2023-06-28
中国河南省郑州市金水区蜘蛛爬虫ip大全
 干货   2023-06-22
javascript简易动态时间代码
 干货   2023-06-20
感谢员工的付出和激励的话怎么说?
 干货   2023-06-18
 
>>返回首页<<
 
 
 
静静地坐在废墟上,四周的荒凉一望无际,忽然觉得,凄凉也很美
© 2005- 王朝网络 版权所有