资源简介
duilib嵌入cef3, 并和js交互
代码片段和文件信息
#include “MainWnd.h“
#include “include\cef_browser.h“
CMainWnd::CMainWnd(void): m_handler(new SimpleHandler)
{
}
CMainWnd::~CMainWnd(void)
{
}
void CMainWnd::InitWindow()
{
m_pBtnClose = static_cast(m_PaintManager.FindControl(L“btn_close“));
m_pURL = static_cast(m_PaintManager.FindControl(L“edit_url“));
m_pBtnGo = static_cast(m_PaintManager.FindControl(L“btn_go“));
m_pBtnBack = static_cast(m_PaintManager.FindControl(L“btn_back“));
m_pBtnCallJs = static_cast(m_PaintManager.FindControl(L“btn_calljs“));
RECT rt;
::GetClientRect(m_hWnd &rt);
rt.top += 100;
rt.bottom -= 3;
rt.left += 3;
rt.right -= 3;
CefWindowInfo info;
info.SetAsChild(m_hWnd rt);
CefBrowserSettings settings;
CefBrowserHost::CreateBrowser(info m_handler.get() L“http://www.baidu.com“ settings NULL);
}
void CMainWnd::OnFinalMessage( HWND hWnd )
{
while(m_handler->GetBrowser())
{
Sleep(10);
}
::PostQuitMessage(0);
}
void CMainWnd::Notify(TNotifyUI& msg)
{
if(msg.sType == DUI_MSGTYPE_CLICK)
{
if(msg.pSender == m_pBtnClose)
{
//
Close();
}
else if(msg.pSender == m_pBtnCallJs)
{
CefRefPtr msg = CefProcessMessage::Create(“callback_func“);
CefRefPtr args = msg->GetArgumentList();
args->SetString(0 “call js call back function“);
args->SetInt(1 10);
m_handler->GetBrowser()->SendProcessMessage(PID_RENDERER msg);
}
else if(msg.pSender == m_pBtnGo)
{
if(m_pURL->GetText().Compare(L““) == 0)
{
m_handler->GetBrowser()->GetMainframe()->Executejavascript(L“alert(\“url is empty\“);“ m_handler->GetBrowser()->GetMainframe()->GetURL() 0);
return ;
}
std::wstring strUrl = m_pURL->GetText();
if(!m_pURL->GetText().IsEmpty() /*&& m_pURL->GetText().Compare(L““) != 0*/)
m_handler->GetBrowser()->GetMainframe()->LoadURL(strUrl);
}
else if(msg.pSender == m_pBtnBack)
{
//m_handler->GetBrowser()->GoBack();
CallJsFunc(L“GoBack()“);
}
}
}
LRESULT CMainWnd::HandleCustomMessage(UINT uMsg WPARAM wParam LPARAM lParam BOOL& bHandled)
{
if(uMsg == WM_SIZE)
{
HWND hwnd = ::FindWindowEx(m_hWnd NULL L“CefBrowserWindow“ NULL);
::MoveWindow(hwnd 3 100 LOWORD(lParam)-6 HIWORD(lParam)-103 TRUE);
}
else if(uMsg == WM_DROPFILES)
{
WCHAR wcFile[MAX_PATH] = {0};
UINT count = DragQueryFile((HDROP)wParam 0xFFFFFFFF NULL 0);
if(count)
{
DragQueryFile((HDROP)wParam 0 wcFile MAX_PATH);
wstring str = wcFile;
m_handler->GetBrowser()->GetMainframe()->LoadURL(str);
m_pURL->SetText(wcFile);
}
}
else if(uMsg == WM_COPYDATA)
{
COPYDATASTRUCT* pData = (COPYDATASTRUCT*)lParam;
::MessageBox(NULL (LPCWSTR)pData->lpData L“js func“ MB_OK);
}
return 0;
}
void CMainWnd::CallJsFunc(LPCWSTR strJSFuncName)
{
if(strJSFuncName[0] == L‘\0‘ || strJSFuncName == NULL)
return;
m
- 上一篇:蜜蜂剪辑破解版.zip
- 下一篇:7.8.rar
相关资源
- 让Duilib完美支持gif
- CEF3 chromium 68.3440 with mp3/mp4 2018-08
- duilibDemo
- 基于cef4delphi 的 cef3内核 多标签浏览器
- VirtualList.7z
- Duilib ListUI扩展 源码
- Cef3博文配套源代码
- duilib官方帮助文档
- DuiCef
- 仿记事本Demo
- DUIlib使用Fastreport
- Duilib控件穿透测试代码
- Duilib中的可拖放节点的树实现
- 的按钮图片资源
- CEF3 chromium 2623 /mp3/mp4 稳定、终结版
- DuiLib帮助文档.chm
- DuilibPreview.rar
- duilib 仿酷狗 QQ调色板修改版3
- duilib IE去边框和滚动条
- duilib中UIList支持多选+右键菜单Demo
- duilib获取CSliderUI滑动事件 - 用自定义
- CEF3使用说明-中文
- DUILIB入门简明教程
- duilib Designer exe程序及动态库附大量
评论
共有 条评论