代码拉取完成,页面将自动刷新
#include "windows.h"
#include "include/cef_app.h"
#include <include/internal/cef_win.h>
#include "include/cef_client.h"
class ClientHandler :public CefClient, public CefLifeSpanHandler
{
public:
virtual CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() { return this; }
//CefLifeSpanHandler
virtual void OnAfterCreated(CefRefPtr<CefBrowser> browser) { browser_ = browser; }
CefRefPtr<CefBrowser> browser_;
IMPLEMENT_REFCOUNTING(ClientHandler);
};
class ClientApp :public CefApp, public CefBrowserProcessHandler
{
public:
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() {
return this;
}
virtual void OnContextInitialized()
{
CefWindowInfo window_info;
window_info.SetAsPopup(NULL, L"CefTmp");
CefBrowserSettings setting;
CefBrowserHost::CreateBrowser(window_info, new ClientHandler, L"http://www.baidu.com", setting, NULL);
}
IMPLEMENT_REFCOUNTING(ClientApp);
};
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
CefEnableHighDPISupport();
// Provide CEF with command-line arguments.
CefMainArgs main_args(::GetModuleHandle(NULL));
CefRefPtr<ClientApp> app{ new ClientApp };
int exit_code = CefExecuteProcess(main_args, app, NULL);
if (exit_code >= 0) {
// The sub-process has completed so return here.
return exit_code;
}
CefSettings settings;
settings.no_sandbox = true;
settings.remote_debugging_port = 8080;
CefInitialize(main_args, settings, app.get(), NULL);
CefRunMessageLoop();
CefShutdown();
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。