Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÔÚJavaScript µ÷ÓÃC++

·½°¸Ò»£º
// 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
CXXXDlg::OnBeforeNavigate2( LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName,
CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel )
{
CString strUrl = lpszURL;
if(strUrl.Left(4) == _T("app:"))
{
// cancel the common url navigate and call your c++ code here
*pbCancel = TURE;
// call other c++ function here or parse the argument in the strUrl

}
// go common url navigate here

}

·½°¸¶þ£º
// 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 ½Ó¿Ú
// .h
class CImpIDispatch : public IDispatch
{
protected:
ULONG m_cRef;
public:
CImpIDispatch(void);
~CImpIDispatch(void);
STDMETHODIMP QueryInterface(REFIID, void **);
STDMETHODIMP_(ULONG) AddRef(void);
STDMETHODIMP_(ULONG) Release(void);
//IDispatch
STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
STDMETHODIMP GetTypeInfo(/* [in] */ UINT iTInfo,
/* [in] */ LCID lcid,
/* [out] */ ITypeInfo** ppTInfo);
STDMETHODIMP GetIDsOfNames(
/* [in] */ REFIID riid,
/* [size_is][in] */ LPOLESTR *rgszNames,
/* [in] */ UINT cNames,


Ïà¹ØÎĵµ£º

º¯ÊýµÄ½âÎöÖ®C/C++

      º¯ÊýÊdzÌÐòµÄÖ´ÐÐÄ£¿é£¬ÊÇÕû¸öÏîÄ¿µÄϸ°û£¬ÈçºÎ×éÖ¯ºÃÿһ¸öº¯ÊýµÄ½á¹¹£¬ÈçºÎÌá¸ß³ÌÐòµÄ¿É¶ÁÐÔºÍÔËÐÐЧÂÊ£¬ÊdzÌÐòÔ±ÃDz»¶ÏƷζµÄÖ÷Ìå¡£ÓÐʱº¯ÊýµÄÉè¼ÆÄÜÖ±½ÓÌåÏÖ³ö³ÌÐòÔ±¶ÔC/C++µÄÀí½âºÍ¸ÐÎò¡£
      C/C++µÄº¯ÊýÀàÐͲ»¶ÔÍâºõÒÔϼ¸ÖÖ£¬ÓÐЩÃèÊö¿ÉÄܲ»Ì«ÌùÇУº
......

JavaScript Calls from C++

×î½üÒªÓõ½Ïà¹Ø¼¼Êõ£¬ÏÈÌùÔÚÕ⣬ÓпÕÔÙ·­Ò³¡£
±¾ÎÄת×Ô£º
http://www.codeguru.com/Cpp/I-N/ieprogram/article.php/c4399
http://www.codeguru.com/cpp/i-n/ieprogram/article.php/c4399/JavaScript-Calls-from-C.htm
http://www.codeproject.com/KB/COM/jscalls.aspx

Introduction
Sometimes, when we are usi ......

ÓÀÔ¶Éñ»°——C#/C/C++µ½µ×»¹ÄÜ×öʲô£¿

http://blog.csdn.net/tonyxiaohome/archive/2010/04/27/5536367.aspx
ÎÒ¿´ÁËÒÔºóÎÒҲ˵¼¸¾ä£¬ËãÎÒÔÚITÐÐÒµ´òƴһЩ¾­Ñé¡£
 Ê×ÏÈÕâ¸ö»°ÌâʵÔÚÊÇÌ«´óÁË¡£
C++ °üÀ¨C²»£¿
Æ»¹û¡¢Ò»Ð©Èí¼þ ±ÈÈçMysql£¬sqlite ¶¼ÊÇÄ£¿é»¯ÎªÖ÷
»ù±¾¾ÍÊÇCÓïÑÔ¡£
 Ê×ÏÈÎÒ²»ÈÏͬ C++°üÀ¨C¡£
Õâ¸ö»°Ìâ ¾ÍÓÐÎÊÌâ¡£
ÎÒÃǸĸĿ´  ......

javascriptЧÂʾ­Ñé̸(Ò»)

±¾ÎÄÖ÷ÒªÊdzöÓÚÓÐÅóÓÑʹÓÃÎÒÔ­À´Ð´µÄautocompleteµÄJS¿Ø¼þ¡£µ±Êý¾ÝÁ¿´óµÄʱºò£¬»á³öÏÖЧÂʼ«ÆäÂýµÄÇé¿ö£¬ÎÒÔÚÕâ¶Îʱ¼ä×ö³öµÄһЩ²âÊÔÒ²¼°Ò»Ð©¾­Ñ飬Óë´ó¼Ò·ÖÏí£¬Èç¹ûÓдíµÄµØ·½£¬»¹ÇëÖ¸³ö¡£
¾­¹ý²âÊÔ£¬ÎÒÃǻᷢÏÖÈçϵÄÇé¿ö»òÕß˵µÄ½áÂÛ£¬Èç¹ûÄúµÄ²âÊÔ½á¹ûÓëÎҵIJ»·û£¬Çë˵Ã÷Ô­Òò£¬ÒÔ±ãÏ໥ѧϰ¡£
1£©µ±Ò»¸ö½Ï´óµÄHTML×Ö· ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ