大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> 其他相关 -> 简单ocx控件制作方法

简单ocx控件制作方法

时间: 2021-07-31 作者:daque

 b/s体例中,存户端javascript的实行功效不高,演算速率慢,很多功夫不得不沿用ocx控件来实行少许功效。将大略的ocx的控件的创造本领供给给大师,一个参考。翻开microsoft visual c++6.0,兴建一个mfc activex工程,如次图:

点击决定,展示activex controlwizard,如次图:

简单ocx控件制作方法

采用next展示下来界面连接采用next,创造工程helloworld:

在helloworldctl.cpp中,窜改如次场合: // dispatch and event ids public:  enum {  //{{afx_disp_id(chelloworldctrl)  // note: classwizard will add and remove enumeration elements here.  // do not edit what you see in these blocks of generated code !  dispidgethello = 1l,  //}}afx_disp_id  }; };

简单ocx控件制作方法

而后增添声明 begin_dispatch_map(chelloworldctrl, colecontrol) //{{afx_dispatch_map(chelloworldctrl) disp_function(chelloworldctrl,"gethello",gethello,vt_bstr, vts_bstr) //}}afx_dispatch_map end_dispatch_map()

简单ocx控件制作方法

接着增添分子 // message maps //{{afx_msg(chelloworldctrl) // note - classwizard will add and remove member functions here. // do not edit what you see in these blocks of generated code ! afx_msg bstr gethello(lpctstr strbatchname); //}}afx_msg

增添本领,这个本领归来"hello world!"加上输出参数strbatchname。 bstr chelloworldctrl::gethello(lpctstr strbatchname)  {   cstring aa = (cstring)strbatchname ;   cstring rtnstr = "hello world!" + aa;   return rtnstr.allocsysstring();  }

结果在build的configration中采用下图办法,编写翻译实行,在release文献夹下爆发ocx.

简单ocx控件制作方法

接着即是尝试了:将ocx索取出来,我沿用microsoft control pad来编纂,获得ocx控件的classid, 而后创造一个html页面,写入javascrip剧本,挪用ocx中的本领。 将编写翻译经过的release目次的helloworld.ocx与html寄存在同一文献夹下,翻开html页面,页面将谈出对话框,消息为"hello world!-- applegreen".

简单ocx控件制作方法

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.