您的位置:首页 > 其它

MFC嵌入cef3

2014-10-24 15:38 330 查看
全局变量:
CefRefPtr<ClientApp> CefApp=NULL;

重写MFC启动代码:

//添加以下代码,开始
CefMainArgs main_args;//(hInstance);
CefApp = new ClientApp();

// Execute the secondary process, if any.
int exit_code = CefExecuteProcess(main_args, CefApp.get(), NULL);
if (exit_code >= 0)
return exit_code;

// Parse command line arguments. The passed in values are ignored on Windows.
// AppInitCommandLine(0, NULL);

CefSettings settings;
settings.multi_threaded_message_loop=true;
//settings

// Populate the settings based on command line arguments.
// AppGetSettings(settings);

// Initialize CEF.
if(!CefInitialize(main_args, settings, CefApp.get(), NULL))
{
ASSERT(0);
}
//结束
CWinThread *pThread = AfxGetThread();//获取主线程指针
CWinApp *pApp = AfxGetApp();
AfxWinInit();
....
pApp->InitApplication();
...
pThread->InitInstance();//初始化应用程序实例
...
nReturnCode = pThread->Run();//开始消息循环
CefShutdown();
return nReturnCode;

}


在MFC中void CMainFrame::OnClose()添加以下代码

?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: