Archive
CEFWrappers v1.0
I was looking to embed Chromium recently in a desktop Windows MFC application and was looking for examples. An excellent starting point is https://www.codeproject.com/Articles/1105945/Embedding-a-Chromium-Browser-in-an-MFC-Application from MVP Marius Bancilla. I decided to take that as the basis and implement a fresh MFC sample from scratch using the latest version of CEF. Thus was born CEFWrappers. This is a collection of freeware MFC classes which implement a fully embeddable Chromium window in a MFC desktop app using Visual C++ 2019 or later and MFC.
Usage
- To use CEFWrappers in your code simply include CEFWrappers.h and CEFWrappers.cpp in your project and #include CEFWrappers.h in which ever of your modules needs to make calls to the various classes.
- You need to download and build CEF for Windows or download prebuilt binaries for CEF. Details are included in the codeproject article. You can download builds from http://opensource.spotify.com/cefbuilds/index.html. If you want to build CEF yourself, there is a article explaining how to do this at http://mariusbancila.ro/blog/2016/05/05/building-the-64-bit-version-of-chromium-embedded-framework-on-windows/.
- The demo application only provides x64 builds as that is all I needed but CEF builds are available for x86 Windows.
- The demo application assumes you have download and built CEF to "d:\dev\CEF". If you have CEF located somewhere else then you will need to amend the demo projects VC++ Directory settings.
- Your application must be linked to the same version of the C Runtime as that used by the CEF libcef_dll_wrapper project in the CEF download. The default is multi-threaded static version (/MT or /MTd). If you application is using the multi-threaded DLL (/MD or /MDd) setting then you will need to rebuild CEF to match this.
- To successfully use CEF in your application your application must include a manifest file to indicate support for various versions of windows. If you do not do this then you will get linker errors indicating that you are mixing your C runtimes. Please see CEFDemo.exe.manifest in the download for details.
- The classes are designed for VC 2019 or later. They have not been tested on earlier releases of VC.
- The class CCefAppHandler in the demo application is responsible for process specific callbacks from CEF.
- The class CCEFDelegate in CEFWrappers is the main callback interface which is used by CEFWrappers framework.
- The class CCEFClientHandler is responsible for Browser specific callbacks from CEF and will end up calling CCEFDelegate virtual functions as required. Note currently this class implements support for CefClient, CefDisplayHandler, CefLifeSpanHandler, CefLoadHandler, CefRequestHandler & CefResourceRequestHandler CEF interfaces. There are numerous other CEF interfaces which could be included in this class going forward.
- The class CCEFView implements a standard CView derived class which you can reuse in your application to host a CEF browser window.
- The class CCEFDoc is a CDocument derived class to go along with the CCEFView class.
- All places which show CEF integration in a typical MFC MDI application are highlighted in the CEFWrappers code using a "//CEF_INTEGRATION" comment, which you are search for.
- The sample application shows a custom URL of http://tests/intro.html which is implemented using embedded resources in the demo application. This is implemented using classes called CCEFDemoBinaryResourceProvider & CCEFDemoClientHandler in the application. The intro.html is the main start page for each new MDI browser child window and provides links to four other example pages. These include a PDF file embedded in a html page, a standalone PDF file and two png image files.
- Please note that the sample application is a bare bones example of CEF integration and features such as Print, Print Preview, Cut, Copy, Paste, download support etc are missing. For examples of this please check our the cefclient sample application in the CEF download.
- Please note that during testing of the demo application with CEF, I got inconsistent errors reported in the debugger when calling CefShutdown during application shutdown. This I believe is due to some resources not being correctly released using a reference counting mechanism which CEF uses throughout its codebase. I was not seeing these errors when testing with the release versions of CEF and the errors were inconsistent, random and not URL specific. CEF recommends a two stage approach to clean application shutdown as documented as https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage.md#markdown-header-browser-life-span. I initially implemented this approach in the demo application in CEFWrappers, but was still getting inconsistent errors on shutdown so I have left the code using a DestroyWindow API approach in the CCEFView::CloseBrowser method which is called by CMainFrame::OnClose as part of demo application’s normal shutdown. This is the approach used by the SDI application in the CodeProject article. If any person has advice on how to improve this, please let me know.
- Once you have got everything compiled and working, you will need to ship additional files with your application to support CEF at runtime. These files are documented in the README.txt file in the root directory of the CEF download. This will comprise approximately 166 MB of files for the latest Windows 64-bit 79.1.36+g90301bd+chromium-79.0.3945.130 version of CEF.
- For further information on developing with CEF and the functionality it provides, please review the comprehensive documentation on the CEF wiki web site at https://bitbucket.org/chromiumembedded/cef/wiki/Home.
PyDebug++ v1.15
Just to let everyone know that v1.15 of PyDebug++ has been released. Updates for this version include:
- Updated copyright details.
- Fixed an issue where you would get an exception of "I/O operation on closed file" if you debug with the Allocate Console setting to true and then debug again with the Allocate Console setting set to false. Thanks to Changyun Kim for reporting this issue.
MSMQWrappers v1.07
Just to let everyone know that v1.07 of MSMQWrappers has been released. Updates for this version include:
- Updated copyright details
- Fixed more Clang-Tidy static code analysis warnings in the code.
WinHTTPWrappers v1.25
Just to let everyone know that v1.25 of WinHTTPWrappers has been released. Updates for this version include:
- Fixed a bug in the sample app when calling the WinHttpCrackUrl. Thanks to Onur Senturk for reporting this issue.
- Fixed a bug in CSyncDownloader::SendRequestSync where the resources would not be released if the download was successful. Again thanks to to Onur Senturk for reporting this issue.