Azure/C++/C#/Java/Asp.net/JavaScript/Html - MFC/COM/ActiveX/eclipse/Web

dlbrant

working soft

博客园 首页 新随笔 管理

方案一:

 

// html & JavaScript

...

<button value="Click me" onclick="window.navigate('app:command&arg1=1&arg2=2')" />

...

 // C++: 响应 的消息函数OnBeforeNavigat2 

virtual void OnBeforeNavigate2( LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, 

CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel );

// C++ code goes here

Code
方案二:

// html & javaScript

...

function CallCpp()

{

alert('start to call cpp here');

window.external.JavaScriptCallCpp('This is a test for call C++ in JavaScript');

}

<button onclick="CallCpp()" >JavaScript访问C++代码</button>

...

// C++ code goes here

CString javaScriptName = _T("JavaScriptCallCpp");

#define DISPID_CallCppFromJs 1

// 实现IDispatch 接口

Code
// 改写COleControlSit
Code
// 修改App
Code

 

posted on 2009-02-17 14:22  dlbrant  阅读(6274)  评论(3编辑  收藏  举报

Software