vbscript/javascript和COM的数据传递
2009-08-15 11:06
274 查看
我们经常会遇到,将脚本中定义的多个参数打包到一个数组中,然后将这个数组传给一个组件方法。javascript和vbscript定义数组的方式是不 同的。vbscript中的数组采用的是自动化兼容类型SAFEARRAY,对它进行遍历是很方便的。而javascript动态脚本的秘密武器--是IDispatchEx接口
对于一个基本的Object对象,即可以动态的增加或删除属性、方法,也可以生成一个自定义的类,完全基于一个IDispatchEx接口。 IDispatchEx是IDispatch的扩展,为实现动态脚本的一些动态特性量身定制。除了提供IDispatch接口的所有方法之 外,IDispatchEx还额外提供以下几个特性:
Add new members to an object ("expando") — use GetDispID with the fdexNameEnsure flag.
Delete members of an object — use DeleteMemberByName or DeleteMemberByDispID.
Case-sensitive dispatch operations — use fdexNameCaseSensitive or fdexNameCaseInsensitive.
Search for member with implicit name — use fdexNameImplicit.
Enumerate DISPIDs of an object — use GetNextDispID.
Map from DISPID to element name — use GetMemberName.
Obtain properties of object members — use GetMemberProperties.
Method invocation with this pointer — use InvokeEx with DISPATCH_METHOD.
Allow browsers that support the concept of name spaces to obtain the name space parent of an object — use GetNameSpaceParent. ,
ActiveX组件与JavaScript交互 http://hi.baidu.com/huhe/blog/item/817a59ee1ca423f8b3fb95de.html 介绍了连接点, 数据传递,等
而对于vb的safearray, 推荐使用atl的CComSafeArray<>和CComVariant<>类
对于一个基本的Object对象,即可以动态的增加或删除属性、方法,也可以生成一个自定义的类,完全基于一个IDispatchEx接口。 IDispatchEx是IDispatch的扩展,为实现动态脚本的一些动态特性量身定制。除了提供IDispatch接口的所有方法之 外,IDispatchEx还额外提供以下几个特性:
Add new members to an object ("expando") — use GetDispID with the fdexNameEnsure flag.
Delete members of an object — use DeleteMemberByName or DeleteMemberByDispID.
Case-sensitive dispatch operations — use fdexNameCaseSensitive or fdexNameCaseInsensitive.
Search for member with implicit name — use fdexNameImplicit.
Enumerate DISPIDs of an object — use GetNextDispID.
Map from DISPID to element name — use GetMemberName.
Obtain properties of object members — use GetMemberProperties.
Method invocation with this pointer — use InvokeEx with DISPATCH_METHOD.
Allow browsers that support the concept of name spaces to obtain the name space parent of an object — use GetNameSpaceParent. ,
ActiveX组件与JavaScript交互 http://hi.baidu.com/huhe/blog/item/817a59ee1ca423f8b3fb95de.html 介绍了连接点, 数据传递,等
而对于vb的safearray, 推荐使用atl的CComSafeArray<>和CComVariant<>类
相关文章推荐
- 关于vbscript 与 javascript如何传递变量(包括服务器端与客户端)
- flask通过template向javascript传递数据的方法
- (转载)Javascript操作表单之间的数据传递
- javascript控制表单之间的数据传递方法
- 如何在JavaScript与ActiveX之间传递数据(一)
- Javascript 表单之间的数据传递
- 利用javascript实现html之前的数据传递
- javascript和php传递数据
- 一篇清楚阐述 JAvaScript 传递数据 到 Flash 的文章
- Javascript 表单之间的数据传递
- 深入浅析JavaScript中数据共享和数据传递
- javascript表单之间的数据传递! 选择自 itfly 的 Blog
- php传递数据给javascript
- javascript表单之间的数据传递
- 如何在JavaScript与ActiveX之间传递数据(二)
- 把javascript,vbscript中得数组传递给COM组件(or Activex)
- javascript实现父子页面数据传递
- 服务端vbscript与客户端javascript传递变量
- jsp javascript servlet 数据传递总结
- javascript表单之间的数据传递!