简单的CEF项目不显示页面



尝试使用C++中的CEF。制作简单的项目:

#include <Windows.h>
#include <include/cef_app.h>
#include <include/cef_client.h>
#include <include/wrapper/cef_helpers.h>
class Handler : public CefClient {
public:
private:
IMPLEMENT_REFCOUNTING(Handler);
};
class App : public CefApp, public CefBrowserProcessHandler {
public:
CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override {
return this;
}
void OnContextInitialized() override {
CEF_REQUIRE_UI_THREAD();
CefRefPtr<Handler> handler(new Handler);
CefWindowInfo wndInfo;
wndInfo.SetAsPopup(0, "Hello world");
CefBrowserSettings settings;
std::string url{ "https://stackoverflow.com" };
CefBrowserHost::CreateBrowser(wndInfo, handler, url, settings, nullptr, nullptr);
}
private:
IMPLEMENT_REFCOUNTING(App);
};
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
CefEnableHighDPISupport();
CefMainArgs args(hInstance);
int ec = CefExecuteProcess(args, nullptr, nullptr);
if (ec >= 0) {
return ec;
}
CefSettings settings;
CefRefPtr<App> app(new App);
CefInitialize(args, settings, app, nullptr);
CefRunMessageLoop();
CefShutdown();
return 0;
}

项目文件夹包含来自cefclient(官方cef示例(的所有文件

08.04.2020  12:21         2 133 001 cef.pak
08.04.2020  12:21           654 037 cef_100_percent.pak
08.04.2020  12:21           808 292 cef_200_percent.pak
08.04.2020  12:21         1 772 827 cef_extensions.pak
08.04.2020  12:21         1 110 016 chrome_elf.dll
08.04.2020  12:21         4 346 120 d3dcompiler_47.dll
08.04.2020  12:21         7 015 266 devtools_resources.pak
08.04.2020  12:21        10 505 952 icudtl.dat
08.04.2020  12:21       158 316 032 libcef.dll
08.04.2020  12:21           391 168 libEGL.dll
08.04.2020  12:21        10 552 832 libGLESv2.dll
08.04.2020  12:44    <DIR>          locales
09.04.2020  18:14           613 247 main.obj
09.04.2020  18:14         3 948 032 Project1.exe
08.04.2020  12:21           606 640 snapshot_blob.bin
08.04.2020  12:49    <DIR>          swiftshader
08.04.2020  12:21           923 968 v8_context_snapshot.bin
09.04.2020  18:14           519 168 vc142.idb
09.04.2020  18:14           847 872 vc142.pdb

为什么我能得到一张空白页?

已解决。添加清单文件

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
<dependentAssembly>
<assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
</dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--The ID below indicates application support for Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!--The ID below indicates application support for Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!--The ID below indicates application support for Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

相关内容

  • 没有找到相关文章

最新更新