Visual C++ã§ã¯ãWPFã使ãã¾ããã
æ¨æºã§ç¨æããã¦ããVisual C++ã®ã³ã³ããã¼ã«ã¯ã
è¦ãç®ãå°å³ã§ã種é¡ãå°ãªãã§ãã
ãããå«ãªããæç»é¢æ°ã¨ã¤ãã³ããé§ä½¿ãã¦ãèªåã§ä½ããã
C++/CLIã§WPFãå©ç¨ããããããã¾ããã
ãããªGUIã貧弱ã«ãªããã¡ãªVisual C++ã§ã
WPFã£ã½ãã¦ã£ã³ãã¦ãä½ã£ã¡ãããï¼ã¨ããã話ããã¾ãã
ããããã®æ¹æ³ã ã¨ã.NET2003ãããã®å¤ãVisual C++(ver7.1)ã§ãWPFã£ã½ããã¨ãã§ãã¦ãã¾ãã¾ãã
ä½ã使ãããç°¡åã«è¨ãã¨ã
CDHtmlDialogã¨ãSilverlight(JavaScriptãã¼ã¹)ã§ãã
å®ã¯ããããã§ã»ã¨ãã©ã®èª¬æã¯çµãããªã®ã§ããâ¦â¦ï¼
CDHtmlDialogã¯CHtmlViewã§ããããã¨æãã¾ããã
CDHtmlDialogã¯Dynamic HTMLãæ±ããããã«ãªã£ã¦ããã®ã§ã楽ã§ãã
CDHtmlDialogã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ãHTMLãèªã¿è¾¼ã¿ã
HTMLã«é¢é£ä»ããããJavaScriptãå®è¡ãã¦Silverlightãå¶å¾¡ãããã¨ãã£ãæãã§ãã
C++é¨åã«å¦çã®ä¸æ ¸ï¼Modelï¼ãæ å½ãããSilverlightã¯è¡¨ç¤º(View)ã«ç¹åãã¾ãã
ã¨ãããã¨ã§ãC++ãâãSilverlightã¸éä¿¡ããæ¹æ³ãå¿ è¦ã¨ãªãã¾ãã
ãã¦ããã®æ¹æ³ã§ãããJavaScriptã仲ä»ãã¦è¡ãã¾ãã
Visual C++ â JavaScript â Silverlight
ã¨ããæãã«ãVisual C++ããJavaScriptã®é¢æ°ãã³ã¼ã«ãã
ãã®å¼ã³åºãããé¢æ°ãSilverlightã®æç»ãæ¸ãæããå¦çãè¡ãã
ã¨ãã£ãæ¹æ³ãã¨ãã¾ãã
C++ããJavaScriptãã³ã¼ã«ããæ¹æ³ã«ã¤ãã¦ã§ããã
CDHtmlDialogã®ã¡ã³ãå¤æ°ãm_spHtmlDocãç¨ãã¦è¡ããã¨ãã§ãã¾ãã
ãã®æ¹æ³ã«ã¤ãã¦ããã£ã¨å¦çæ¦è¦ã ãæ¸ãã¾ãã
C++å´ã®ã³ã¼ããµã³ãã«(CDHtmlDialogã®æ´¾çã¯ã©ã¹ã«è¨è¿°)
ç¾å¨ã®ãã¼ã¸ã«ãã¼ãããã¦ãããhelloworldãã¨ããé¢æ°ãåå¾ãã¦ã
//ãã¼ã¸ã®Scriptãåå¾
CComPtr<IDispatch> spDisp;
HRESULT hr = m_spHtmlDoc->get_Script(&spDisp);//JavaScripté¢æ°ãhelloworldããåå¾
CComBSTR funcname(L"helloworld");
DISPID dispid = -1;
hr = spDisp->GetIDsOfNames(IID_NULL, &funcname, 1, LOCALE_SYSTEM_DEFAULT, &dispid);//helloworldãå®è¡
DISPPARAMS dispParam = {0, 0, 0, 0}; // JavaScripté¢æ°ã®å¼æ°
EXCEPINFO eInfo; // ä¾å¤æ å ±
UINT argErr = -1; // å¼æ°ã¨ã©ã¼
hr = spDisp->Invoke(dispid, IID_NULL, 0, DISPATCH_METHOD, &dispParam,
&retValue, &eInfo, &argErr);
å®è¡ããããã¨ããã ãã®ã³ã¼ãã§ãã
å¾ã¯ãJavaScriptå´ã§ãé¢æ°helloworldãç¨æããã ãã§ãã
JavaScriptå´ã®ã³ã¼ããµã³ãã«
ä¸è¨ã®ä¾ã§ã¯Silverlightã«é¢ããã³ã¼ãã¯è¨è¿°ãã¦ãã¾ãããã
function helloworld() {
alert("helloworld");
}
JavaScripté¢æ°å ã§ãSilverlightãå¶å¾¡ããã³ã¼ããæ®éã«è¨è¿°ããã°ã
ã¡ããã¨Silverlightãåä½ãã¦ããã¾ãã
JavaScripté¢æ°ã«VARIANTåå¼æ°ã渡ãå ´åã¯ã
DISPPARAMSã®cArgsã«å¼æ°ã®åæ°ãè¨å®ããrgvargã«å¼æ°ã®ãã¤ã³ã¿ã渡ãã¾ãã
æ°å¤ãæååã¯ããã§æ¸¡ãã¾ãããArrayåãªã©ã®ååã¤ããªãã¸ã§ã¯ãã渡ãã®ã¯ãããªãé¢åãããã§ãã
åºæ¥ãªãã¯ãªãã§ãããè¤éã§ãã
ã¨ãããããC++âSilverlightã¯ããã§å¶å¾¡ã§ãã¾ãã
SilverlightâC++ã¯ãè¥å¹²å·¥å¤«ãå¿ è¦ã«ãªãã¾ãã
çµå±JavaScriptã仲ä»ãããã®ã§ãããC++ â JavaScriptããé¢åã§ãã
ãã£ãé¢åã ã¨æ¸ããããååä»ããªãã¸ã§ã¯ããå¼æ°ã§æ¸¡ããæ¹æ³ã¨ãè¥å¹²ä¼¼ã¦ãã¾ãã
é·ããªã£ãã®ã§ç¶ãã¯æ¬¡åã