46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using CefSharp;
|
|
using CefSharp.WinForms;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace WindowsFormsApp1
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public ChromiumWebBrowser chromeBrowser;
|
|
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
|
|
CefSettings settings = new CefSettings();
|
|
// Initialize cef with the provided settings
|
|
Cef.Initialize(settings);
|
|
// Create a browser component
|
|
chromeBrowser = new ChromiumWebBrowser("https://www.baidu.com");
|
|
// Add it to the form and fill it to the form window.
|
|
chromeBrowser.Dock = DockStyle.Fill;
|
|
this.Controls.Add(chromeBrowser);
|
|
|
|
|
|
}
|
|
//窗体关闭时,记得停止浏览器
|
|
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
Cef.Shutdown();
|
|
}
|
|
|
|
private void chromiumWebBrowser1_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|