客户端如何实现对MFC ActiveX的Event 的调用介绍
来源:互联网 发布:unix socket编程 编辑:程序博客网 时间:2024/04/30 11:41
请参看codeproject上的文章:
http://www.codeproject.com/KB/COM/ActiveXMfcState.aspx
Building the MFC client
Our MFC client, is a plain old Appwizard generated Dialog-based application with additional Automation support. As usual, open VC++ 6.0 and create a new MFC Appwizard EXE project called MFCClient. Hit Build to build the project, and take a break from all that hard work!
The OLE/COM Object Viewer is a nifty little tool that is shipped along with Visual C++ 6.0. It will help us generate the IDL file for the DLL component. Go to Tools->OLE/COM Object Viewer and open this tool. Next, in OLE/COM Object Viewer, click on File->View Typelib and navigate to the VBEvent.dll file that we have previously built. Ready for some magic? Click on Open and open up ITypeLib Viewer Can you can view the IDL file? Whoa! Save the file through File->Save As, as VBEvents.IDL and close the tool. We have no need for it at present.
Next in our VC++ project, add this IDL file to the project. In FileView, right click on the IDL file and choose Settings. In the MIDL tab, set the Output header file name to VBEvents.h and the UUID filename to VBEvents_i.c. Also deselect the MkTyplib compatible option.
Save everything and in FileView, right-click on the VBEvents.IDL file and choose Compile. This will build the typelibrary and generate the necessary files.
Examine the MIDL generated VBEvents_i.c file. It contains all the UUID definitions that the client can use to build a sink object. In VBEvents.h, notice the dual interface _clsEventSrc. The component's dispinterface __clsEventSrc is identified by DIID___clsEvent. This is the event source for out custom event.
The next step is to add an sink object to connect to the source event. Fortunately, for us, MFC makes the task of building an event sink as easy as 1-2-3 (and well,4-5-6) With a couple of MFC macros, you can delegate much of the intricacy involved behind building a sink to MFC. First, add a new CCmdTarget derived class to the project called MFCSink. In the ClassWizard choose to select the Automation option. This is our sink object with Automation support.
Then import the server's typelib in the client with #import. If you haven't read my previous article, read it here.
同时关注微软的ActiveX例子:Circ
- 客户端如何实现对MFC ActiveX的Event 的调用介绍
- MFC ActiveX ISafeObject的实现
- MFC:启用对ActiveX控件的支持
- MFC ActiveX的创建和调用
- C#中对ActiveX控件的调用
- C#中对ActiveX控件的调用
- C#中对ActiveX控件的调用
- python调用wcf服务 实现网站对客户端的调用
- 如何在JavaScript中调用MFC的ActiveX控件的方法
- 基于MFC的activex控件实现ObjectSafety
- MFC中忘记了打开对ActiveX的支持怎么办?
- MFC用COM方式调用ActiveX类型的DLL
- 新建一个MFC ActiveX ControlWizard,调用已经存在的OCX
- 【智能合约】客户端和web端对智能合约的事件Event进行调用的代码示例
- IE调用Activex控件时EVENT的三种调用方式
- 如何判断客户端是否安装了指定的ActiveX控件
- 如何判断客户端是否安装了指定的ActiveX控件
- ActiveX的简单介绍
- linux ls 命令 最常用的选项
- 数据加密
- qsort&&bsearch
- powerbuilder 读取excel报表中的隐藏列
- Linux 的多线程编程的高效开发经验
- 客户端如何实现对MFC ActiveX的Event 的调用介绍
- 指针常量
- Delphi 2007安装问题
- Ajax里的onreadystatechange的作用是什么
- Lucene为数据库建立索引
- WITH AS的用法
- 什么是ERP
- Spring核心容器接口
- 求微博框架和设计思路