时间: 2021-07-31 作者:daque
b/s体例中,存户端javascript的实行功效不高,演算速率慢,很多功夫不得不沿用ocx控件来实行少许功效。将大略的ocx的控件的创造本领供给给大师,一个参考。翻开microsoft visual c++6.0,兴建一个mfc activex工程,如次图:
点击决定,展示activex controlwizard,如次图:
采用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 }; };
而后增添声明 begin_dispatch_map(chelloworldctrl, colecontrol) //{{afx_dispatch_map(chelloworldctrl) disp_function(chelloworldctrl,"gethello",gethello,vt_bstr, vts_bstr) //}}afx_dispatch_map end_dispatch_map()
接着增添分子 // 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索取出来,我沿用microsoft control pad来编纂,获得ocx控件的classid, 而后创造一个html页面,写入javascrip剧本,挪用ocx中的本领。 将编写翻译经过的release目次的helloworld.ocx与html寄存在同一文献夹下,翻开html页面,页面将谈出对话框,消息为"hello world!-- applegreen".