SkinUI5.0官方文档

SkinUI5.0官方文档


CEF浏览器

<h2>CEF浏览器控件</h2> <p>CEF浏览器控件CCefView类,继承于CWebView,支持CWebView的所有属性和方法。</p> <h2>请看下面的示例</h2> <h4>效果图</h4> <p><img src="http://www.skinui.cn/doc/img/5.0/3/CefView.png" alt="Cef浏览器控件" /></p> <h4>js文件</h4> <pre><code class="language-js">function sendMessage(jsonParams) { if(window.cefQuery) { window.cefQuery({'request' : jsonParams}); } else { window.external.ieQuery(jsonParams); } } function responseCallback(param) { alert(param); } function CallCPlusPlusFunction1Param() { var jsonParams = '{\ "key": "Function1Param",\ "data": {"param1": "param1"},\ "callback": "responseCallback(\'Function1Param执行成功!\');"}'; sendMessage(jsonParams); } function JavaScriptFunction1Param(param1) { alert(param1); }</code></pre> <h4>布局文件</h4> <pre><code class="language-xml">&lt;FlexLayout&gt; &lt;TextView Width="MatchParent" Height="60" HorzAlign="Center" Text="IDS_CONTROL18_2" Font="ID_FONT_H4"/&gt; &lt;Line Width="MatchParent" Height="1"/&gt; &lt;RelativeLayout Width="MatchParent" Grow="1"&gt; &lt;DemoCefView Id="101" AlignParentLeft="0" AlignParentRight="0" AlignParentTop="0" AlignParentBottom="0"/&gt; &lt;/RelativeLayout&gt; &lt;FlexLayout Width="MatchParent" Height="100" Wrap="Wrap" JustifyContent="Between" AlignContent="Between" Margin="20,20,20,20"&gt; &lt;Button Id="201" Width="30%" Height="WrapContent" ChildText11="C++调用JS方法(1个参数)" Background="Button.png" Layout="Button.xml"/&gt; &lt;Button Id="202" Width="30%" Height="WrapContent" ChildText11="C++调用JS方法(2个参数)" Background="Button.png" Layout="Button.xml"/&gt; &lt;Button Id="203" Width="30%" Height="WrapContent" ChildText11="C++调用JS方法(3个参数)" Background="Button.png" Layout="Button.xml"/&gt; &lt;Button Id="204" Width="30%" Height="WrapContent" ChildText11="C++调用JS方法(4个参数)" Background="Button.png" Layout="Button.xml"/&gt; &lt;Button Id="205" Width="30%" Height="WrapContent" ChildText11="C++调用JS方法(5个参数)" Background="Button.png" Layout="Button.xml"/&gt; &lt;Button Id="206" Width="30%" Height="WrapContent" ChildText11="C++调用JS方法(6个参数)" Background="Button.png" Layout="Button.xml"/&gt; &lt;Button Id="207" Width="30%" Height="WrapContent" ChildText11="C++调用JS方法(7个参数)" Background="Button.png" Layout="Button.xml"/&gt; &lt;Button Id="208" Width="30%" Height="WrapContent" ChildText11="C++调用JS方法(8个参数)" Background="Button.png" Layout="Button.xml"/&gt; &lt;Button Id="209" Width="30%" Height="WrapContent" ChildText11="C++调用JS方法(9个参数)" Background="Button.png" Layout="Button.xml"/&gt; &lt;/FlexLayout&gt; &lt;/FlexLayout&gt;</code></pre> <h4>h文件</h4> <pre><code class="language-cpp">#pragma once class CDemoCefView; class CDemoCefWebLayout : public CFlexLayout { public: enum { IDC_WEBVCefW = 101, IDC_BUTTON_RUN_SCRIPT1 = 201, IDC_BUTTON_RUN_SCRIPT2 = 202, IDC_BUTTON_RUN_SCRIPT3 = 203, IDC_BUTTON_RUN_SCRIPT4 = 204, IDC_BUTTON_RUN_SCRIPT5 = 205, IDC_BUTTON_RUN_SCRIPT6 = 206, IDC_BUTTON_RUN_SCRIPT7 = 207, IDC_BUTTON_RUN_SCRIPT8 = 208, IDC_BUTTON_RUN_SCRIPT9 = 208, }; public: CDemoCefWebLayout(CView* pParent); public: virtual void OnBuildFinish(); protected: void OnBtnClickedRunScript(UINT uNotifyCode, int nID, CView* pView); SKINUI_DECLARE_MESSAGE_MAP() private: CDemoCefView* m_pDemoCefView; SKINUI_DECLARE_DYNCREATE(CDemoCefWebLayout, CFlexLayout) };</code></pre> <h4>cpp文件</h4> <pre><code class="language-cpp">#include "stdafx.h" #include "DemoCefView.h" #include "DemoCefWebLayout.h" SKINUI_BEGIN_MESSAGE_MAP(CDemoCefWebLayout, CScrollLayout) ON_SKINUI_COMMAND_RANGE(IDC_BUTTON_RUN_SCRIPT1, IDC_BUTTON_RUN_SCRIPT9, OnBtnClickedRunScript) SKINUI_END_MESSAGE_MAP() CDemoCefWebLayout::CDemoCefWebLayout(CView* pParent) : CFlexLayout(pParent) , m_pDemoCefView(NULL) { } void CDemoCefWebLayout::OnBuildFinish() { CFlexLayout::OnBuildFinish(); m_pDemoCefView = dynamic_cast&lt;CDemoCefView*&gt;(GetChildById(IDC_WEBVCefW)); if(m_pDemoCefView) { String strURL = SkinUI::GetCurModulePath() + _T("web\\SkinUI.html"); m_pDemoCefView-&gt;LoadURL(strURL); } } void CDemoCefWebLayout::OnBtnClickedRunScript(UINT uNotifyCode, int nID, CView* pView) { if(m_pDemoCefView) { String strJavaScript; if(nID == IDC_BUTTON_RUN_SCRIPT1) { strJavaScript = _T("JavaScriptFunction1Param('11111');"); } else if(nID == IDC_BUTTON_RUN_SCRIPT2) { strJavaScript = _T("JavaScriptFunction2Param('11111', '22222');"); } else if(nID == IDC_BUTTON_RUN_SCRIPT3) { strJavaScript = _T("JavaScriptFunction3Param('11111', '22222', '33333');"); } else if(nID == IDC_BUTTON_RUN_SCRIPT4) { strJavaScript = _T("JavaScriptFunction4Param('11111', '22222', '33333', '44444');"); } else if(nID == IDC_BUTTON_RUN_SCRIPT5) { strJavaScript = _T("JavaScriptFunction5Param('11111', '22222', '33333', '44444', '55555');"); } else if(nID == IDC_BUTTON_RUN_SCRIPT6) { strJavaScript = _T("JavaScriptFunction6Param('11111', '22222', '33333', '44444', '555555', '66666');"); } else if(nID == IDC_BUTTON_RUN_SCRIPT7) { strJavaScript = _T("JavaScriptFunction7Param('11111', '22222', '33333', '44444', '55555', '66666', '77777');"); } else if(nID == IDC_BUTTON_RUN_SCRIPT8) { strJavaScript = _T("JavaScriptFunction8Param('11111', '22222', '33333', '44444', '55555', '66666', '77777', '88888');"); } else if(nID == IDC_BUTTON_RUN_SCRIPT9) { strJavaScript = _T("JavaScriptFunction9Param('11111', '22222', '33333', '44444', '55555', '66666', '77777', '88888', '99999');"); } m_pDemoCefView-&gt;RunJavaScript(strJavaScript); } }</code></pre>

页面列表

ITEM_HTML