Delphi in Chrome Chromium, CEF3 Learning notes (i)

Source: Internet
Author: User

Official: https://cefbuilds.com/


Introduction to CEF:

The embedded chromium framework (CEF) is an open source project created by Marshall Greenblatt in 2008, and its main purpose is to develop a WebBrowser control based on Google Chromium. CEF supports a range of programming languages and operating systems, and can easily be integrated into new or existing projects.

Its design politics is easy-to-use and performance-minded. The basic framework of CEF includes C + + program interfaces, which are implemented through the interface of the local library, which isolates the operating details of the host program and the Chromium&webkit. It provides tight integration between the browser control and the host program, which supports user plugins, protocols, JavaScript objects, and JavaScript extensions, which the host program can freely download, navigate, context, and print. And with Google Chrome, you can support high-performance and HTML5 technology,


You can see this code in the Cefclient project under the [Test] folder.

File structure:

Include--this folder contains the header files required by the CEF client application

LIBCEF--This folder holds the static library for CEF

Libcef_dll--The dynamic Zipper Library of this folder CEF

Tests--Example of this folder store test

Cefclient-A simple client program

Unittests--CEF Interface Unit test


Browser events:
The application handles browser control events by calling the Cefbrowser and Cefframe methods: A.back, Forward, Reload and Stop Load. Control browser Navigation B.undo, Redo, Cut, Copy, Paste, Delete, select All. Control the selection c.print of the target frame. Prints the target frame d.get Source. Gets the HTML source E.view source of the target frame in the form of a string. Use the cache file to save the HTML source of the destination frame, and open the F.load URL with the system default text viewer. Loads a specific URL to the target frame g.load String. Loads a specific string into the target frame, h.load Stream via a randomly specified virtual URL. Loads a specific binary file into the target frame, loads a specific request to the target framework via a randomly specified virtual URL i.load The J.execute JavaScript: executes a specific javscript within the target framework Make K. Zoom. Scale page content for a specific frame
Inserting Netscape-style plug-ins: CEF supports inserting Netscape-style plug-ins, inserting plug-ins like plug-ins that normally plug into a basic dynamic-link library, but as a separate DLL, it must be created through a container and registered with the Cefregisterplugin () function. If you want to call this function, you have to include the Cef_nplugin.h header file.
JavaScript extension: CEF supports JavaScript extensions that can connect native program source code, demo program you can go to see Cef_v8.h and the Cefregisterextension () method, and cefclient The following demo example, If you want to get more information, you can click the following link: javascriptintegration.
User planning: CEF supports registering and processing user programs like Myscheme://mydomain, and you can check out the Cefregisterscheme () and scheme handler test units in cef_scheme.h for detailed instructions.

Frame Overview: All file prefixes are CEF

Framework creation and destruction: CEF UI messages are hosted in a single thread created by a framework, and users are only responsible forcefinitialize () and Cefshutdown () to build and destroy this thread, but if you set the Cefsettings.multi_threaded_message_loop, This UI message loop can also be run in a separate thread.

Reference count: All frames are inherited from the base class Cefbase, and all instance pointers are managed with cefrefptr smart pointers, and reference counts can be automatically processed using the AddRef () and release () functions.
Platform-agnostic: The CEF framework is designed to be platform agnostic, now it supports Windows,mac Os-x and Linux, in order to seamlessly support multiple platforms, the framework defines a series of platform-agnostic interfaces and type definitions.

Framework interface: Cefbrowser is the main browser window class that can be used to create a new browser window with static functions Createbrowser () and Createbrowsersync ().      Cefframe represents a frame of a browser window, each browser window has a top-level main frame, and the main frame can be obtained using the Getmainframe () method.      Cefclient is the representative interface of the main browser window, which is passed as parameters to Createbrowser () Cefrequest for URLs, methods, sending data and header files, and so on.      The Cefschemehandlefactory class is used to handle requests like myscheme://mydomain similar to customer plans Cefreadhandler and Cefwritehandle is a simple interface for reading and writing data. Cefv8handler,cefv8value and Cefv8context are used to create and access JavaScript objects.
CEF3 Download the file structure:
Bin directory is the main storage DLL, you need to put all the files in the bin directory, copied to your EXE's current folder, otherwise it will be an error! Code 126
Demo For example packages for the compression package SRC main source code section, need to add this src path in the Delphi library
After the installation is complete, create a new Demo1, drag a chromium control out and name it Chrm1, and copy all the files in the bin directory to the current folder of your program, and then drag a button and double-click the Add code:
Chrm1. BROWSER.MAINFRAME.LOADURL (' About:blank '); The first time you must load a blank page before you can browse other pages
Chrm1. Browser.MainFrame.LoadUrl (' The URL you want to browse ');
This is the first example to complete!

Delphi in Chrome Chromium, CEF3 Learning notes (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.