Introduction to installing
Cefsharp
CEF, full name Chromium Embedded Framework, is an open source Web Browser control based on Google's Chromium project. Its main purpose is to embed third-party applications to implement browser-related functions. For example, the compatibility mode of the domestic 360 secure browser is the core of IE, and the speed mode is the Chromium core; the recently launched Microsoft Edge is also based on the Chromium open source project.
CefSharp is the C# version of Cef, allowing Chromium browsers to be embedded in WinForms
Installation steps
Step 1: Right-click the project, click Manage NuGet Packages, enter the Cefsharp keyword search, and select CefSharp.WinForms to install
After the installation is complete, a menu will appear in the toolbox, and you can manually drag out the browser components in the form.
To add a browser to the code, reference using
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CefSharp;
using CefSharp.WinForms;
namespace App
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InitBrowser();
}
public ChromiumWebBrowser browser;
public void InitBrowser()
{
Cef.Initialize(new CefSettings());
browser = new ChromiumWebBrowser("http://www.baidu.com");
Font font = new Font("微软雅黑", 10.5f);
this.Controls.Add(browser);
browser.Font = font;
browser.Dock = DockStyle.Fill;
browser.LoadingStateChanged += new EventHandler<LoadingStateChangedEventArgs>(LoadingStateChangeds);
}
//加载状态
private void LoadingStateChangeds(object sender, EventArgs e)
{
}
}
}
Borderless full screen opening effect