如何利用CEF3创建一个简单的应用程序无法创建

09:36 提问
MFC多文档应用程序中嵌入cef3,启动时一次性启了三个多文档应用程序
新建多文档应用程序,新增了Dialog,在Dialog的OnCreate中实现 了cef的CefExecuteProcess、CefInitialize、CreateBrowser,编译无误,结果运行时一下启了多文档实例,而且网页也没有显示出来。
int CTestDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
if (CDialogEx::OnCreate(lpCreateStruct) == -1)
return -1;
Add your specialized creation code here
CefMainArgs main_args ( AfxGetApp()-&m_hInstance );
CefRefPtr&CCefClientApp& app (new CCefClientApp);
if (CefExecuteProcess(main_args, app.get()) == -1)
CefSettingsTraits::init( &settings);
settings.multi_threaded_message_loop =
CefInitialize (main_args, settings, app.get());
example_cef_handler = new CCefClient();
CefWindowI
GetClientRect(&rect);
RECT rectnew=
rectnew.top=rect.
rectnew.bottom=rect.
rectnew.left=rect.
rectnew.right=rect.
info.SetAsChild(GetSafeHwnd(),rectnew);
CefBrowserSettings settings1;
CefBrowserHost::CreateBrowser(info, example_cef_handler.get(), CefString (""), settings1, NULL);
void CMainFrame::OnTestTest32772()
// TODO: Add your command handler code here
CTestDlg mTestD
mTestDlg.DoModal();
求大神指教一二!
按赞数排序
----------------------同志你好,我是CSDN问答机器人小N,奉组织之命为你提供参考答案,编程尚未成功,同志仍需努力!
LZ你的Demo 还有吗,我研究的也是多文档,真的是要累吐血,可还是没弄出来,方便给个Demo学习一下吗?跪谢啊!
其他相关推荐本例开发环境:WIN10 + VS2015
如果还没有编译CEF3库,请见:
创建一个空的 Windows 应用程序,命名为 SimpleBrowser,如下图:
新建 main.cpp ,编写如下代码:
#include "include/cef_app.h"
#include "include/cef_browser.h"
#include "include/cef_client.h"
#include "include/wrapper/cef_closure_task.h"
#include "include/wrapper/cef_helpers.h"
#include &Windows.h&
class MyClient : public CefClient, public CefLifeSpanHandler
virtual ~MyClient() {}
virtual CefRefPtr&CefLifeSpanHandler& GetLifeSpanHandler() override
return this;
virtual void OnBeforeClose(CefRefPtr&CefBrowser& browser) override
CefQuitMessageLoop();
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(MyClient);
class MyApp : public CefApp, public CefBrowserProcessHandler
virtual ~MyApp() {}
virtual CefRefPtr&CefBrowserProcessHandler& GetBrowserProcessHandler() override { return this; }
virtual void OnContextInitialized() override
CEF_REQUIRE_UI_THREAD();
CefWindowInfo window_
CefRefPtr&MyClient& client(new MyClient());
window_info.SetAsPopup(NULL, "cefsimple");
CefBrowserSettings browser_
CefString url = "";
CefBrowserHost::CreateBrowser(window_info, client, url, browser_settings, NULL);
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(MyApp);
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
CefMainArgs main_args(hInstance);
int exit_code = CefExecuteProcess(main_args, NULL, NULL);
if (exit_code &= 0)
return exit_
settings.no_sandbox = true;
auto myApp = CefRefPtr&MyApp&(new MyApp());
CefInitialize(main_args, settings, myApp.get(), NULL);
CefRunMessageLoop();
CefShutdown();
[工程属性] -& [C/C++] ,将 cef 库的 include 所在目录添加到 [附加包含目录]:
[工程属性] -& [链接器],设置好 [附加库目录] 和 [附加依赖项]:
[工程属性] -& [后期生成事件],在命令行里输入如下内容,将依赖的二进制和资源拷贝过来。另外注意需要将 manifest 清单文件嵌入到最后生成的 exe 中,否则可能无法正常运行。
mt.exe -nologo -manifest "G:\libs\cef\manifest\cef.exe.manifest" "G:\libs\cef\manifest\compatibility.manifest" -outputresource:"$(OutDir)$(TargetFileName)";#1
xcopy G:\libs\cef\lib\Debug\*.dll $(OutDir) /Y /E /F
xcopy G:\libs\cef\lib\Debug\*.bin $(OutDir) /Y /E /F
xcopy G:\libs\cef\Resources\* $(OutDir) /Y /E /F
编译,运行,效果如下:
以上就是用 CEF3 开发的最简单的浏览器。
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:42421次
积分:1398
积分:1398
排名:千里之外
原创:77篇
译文:23篇
文章:48篇
阅读:23655
(2)(2)(8)(30)(7)(32)(4)(8)(7)
(window.slotbydup = window.slotbydup || []).push({
id: '4740881',
container: s,
size: '200,200',
display: 'inlay-fix'}

我要回帖

更多关于 应用程序无法创建 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信