vs2010+soui2+cfe3.3071 implement js call

Posted by plzhelpme on Sun, 20 Feb 2022 18:59:23 +0100

preface

In the previous article The 90.6.0 version of vs2010+cef3 embeds cef3 into the mfc window , part of the windows of mfc are embedded into cef3;
The following continuous test is based on the cef3 test under soui2.
However, one of the pits learned after two days of testing that the version of cef3 used is too new (the latest at present), so from https://cef-builds.spotifycdn.com/index.html Find the 2017 CEF at_ binary_ 3.3071.1649. g98725e6_ Windows 32 version, at the same time, the new project SouiWizard4 is finally realized.

prepare

Download cef_binary_3.3071.1649.g98725e6_windows32, compiled with cmake, I won't talk about this part.
Then CEF330 [add the version number to the folder name here. If there are many CEF versions, it can be more detailed]

These articles constitute a reference in the folder.

Put the file in the project folder

Here is mainly for reference Encounter between rookies and cef (4): Soui off screen rendering package Cef3 detail analysis
And its source code
[since the source code is vs2015 and mine is vs2010, different versions of cef3 are adopted for retesting]

Main part

Project - > properties - > C / C + ± > code generation - > Runtime: multithreaded debugging / MTd

SouiWizard4. Add in CPP

#include "Cef3Loader.h"

namespace SOUI
{
	class SMsgLoopCef : public SMessageLoop
	{
	public:
		virtual BOOL OnIdle(int nIdleCount)
		{	
			Cef3Loader::DoMessageLoop();
			return __super::OnIdle(nIdleCount);
		}
	};

	class SMsgLoopFactory : public TObjRefImpl<IMsgLoopFactory>
	{
	public:
		virtual SMessageLoop *CreateMsgLoop()
		{
			return new SMsgLoopCef;
		}

		virtual void DestoryMsgLoop(SMessageLoop *pMsgLoop)
		{
			delete pMsgLoop;
		}
	};
}

theApp->RegisterWindowClass<SCef3Window>();

// Cef3: Initialize
		Cef3Loader::Initialize();

		// Cef3: MessageLoop
		IMsgLoopFactory *pMsgLoopFac = new SMsgLoopFactory;
		theApp->SetMsgLoopFactory(pMsgLoopFac);
		pMsgLoopFac->Release();

Then continue adding

#ifdef _DEBUG
#pragma comment(lib,"CEF3/lib/x86/Debug/libcef.lib")
#pragma comment(lib,"CEF3/lib/x86/Debug/libcef_dll_wrapper.lib")

#else
#pragma comment(lib,"CEF3/lib/x86/Release/libcef.lib")
#pragma comment(lib,"CEF3/lib/x86/Release/libcef_dll_wrapper.lib")

#endif

Attribute - vc + + Directory - include directory: add CEF330;

Add 4 folders to existing items

Cef3Loader.h and cef3loader Copy CPP to the project directory and add existing items

stdafx. Add in H

#include "browser/Browser.h"
#include "controls/SCef3Window.h"
#include "common/ClientApp.h"
#include "event/ExtendEvents.h"

remind

When running, not only C:\test\SouiWizard4\SouiWizard4\CEF330\bin\x86\Debug and C:\test\SouiWizard4\SouiWizard4\CEF330\Resources need to be copied to Debug

Still need to go https://cef-builds.spotifycdn.com/cef_binary_3.3071.1649.g98725e6_windows32_client.tar.bz2 Download and unzip cefclient Exe copy in

Under release, you also need to: ignore the specific library libcmt lib

About version, CEF_ binary_ 90.6.0+g02ae459+chromium-90.0.4430.85_ Windows 32 is definitely not working. It triggers an unexpected interrupt. There is time to debug slowly in this part (several key functions of cef3 have changed)
This CEF_ binary_ 3.3071.1649. g98725e6_ The previous version of Windows 32 is certainly OK. As for the later version, some versions are also OK.

Interface


Run js

The specific source code download address is VS2010 + soui2 + cfe3 3071 implement js call

Digression: I wanted to be simpler, but because the version is too high, I checked a lot of data in the process of debugging and got a better understanding of cef3, which is also a detour.

In this source code, there are several examples of echarts, such as

At present, I have a project I want to join, which is also the original intention of learning cef3. Now I'm going to change the browser to cef3

Topics: C++