当前位置:网站首页>Getting Started with CefSharp - winform
Getting Started with CefSharp - winform
2022-07-31 03:01:00 【Hometown of 2130】
CefSharp supports HTML, CSS, JavaScript, and can operate like a web site in CS.It is the same as the webBrowser that comes with winform, except that CefSharp is independent and is based on the Chrome browser, while the webBrowser is based on the IE browser.Now simply experience the effect.
1. First create a winform program
Project selection.NET Framework4.8 framework
In nuget, download cefsharp, select version is 83.4.20.If you use a higher version here, there will be a black screen problem.Only this version does not currently, and less than this version does not have a black screen (known after a lot of testing)
2. Then it will report an error if it runs, add the following places
Add the following code to the project file
true
Add to the configuration file
Then restart.
3. In the main interface, add the following code
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 cef1{public partial class Form1 : Form{public ChromiumWebBrowser chromeBrowser;public Form1(){InitializeComponent();}private void Form1_Load(object sender, EventArgs e){InitializeChromium();//Initialization}public void InitializeChromium(){CefSettings settings = new CefSettings();settings.Locale = "zh-CN";// Initialize cef with the provided settingsCef.Initialize(settings);// Create a browser componentchromeBrowser = new ChromiumWebBrowser("https://blog.csdn.net/u012563853");// Add it to the form and fill it to the form window.this.Controls.Add(chromeBrowser);chromeBrowser.Dock = DockStyle.Fill;}private void Form1_FormClosing(object sender, FormClosingEventArgs e){Cef.Shutdown();}}}
4. Effects
边栏推荐
- Multilingual settings of php website (IP address distinguishes domestic and foreign)
- How to build a private yum source
- 分布式与集群是什么 ? 区别是什么?
- Is interprofessional examination difficult?Low success rate of "going ashore"?Please accept this practical guide!
- [Android] Room - Alternative to SQLite
- JetPack component Databinding
- C primer plus学习笔记 —— 8、结构体
- Mysql 45讲学习笔记(二十四)MYSQL主从一致
- Hanyuan Hi-Tech 8-channel HDMI integrated multi-service high-definition video optical transceiver 8-channel HDMI video + 8-channel two-way audio + 8-channel 485 data + 8-channel E1 + 32-channel teleph
- [Godot][GDScript] 二维洞穴地图随机生成
猜你喜欢
CentOS7下mysql5.7.37的安装【完美方案】
YOLOV5学习笔记(三)——网络模块详解
4、敏感词过滤(前缀树)
SQL注入 Less46(order by后的注入+rand()布尔盲注)
10 Permission introduction
品牌广告投放平台的中台化应用与实践
Pythagorean tuple od js
Mysql 45讲学习笔记(二十三)MYSQL怎么保证数据不丢
工程(五)——小目标检测tph-yolov5
Word/Excel fixed table size, when filling in the content, the table does not change with the cell content
随机推荐
YOLOV5 study notes (2) - environment installation + operation + training
知识蒸馏7:知识蒸馏代码详解
软件积累 -- 截图软件ScreenToGif
【C语言】三子棋(经典解法+一览图)
CorelDRAW2022 streamlined Asia Pacific new features in detail
7、私信列表
JS function this context runtime syntax parentheses array IIFE timer delay self.backup context call apply
How to build a private yum source
[Android] Room - Alternative to SQLite
7. List of private messages
f.grid_sample
Clustering index, and what is the difference between a clustering index
Moxa NPort device flaw could expose critical infrastructure to devastating attack
execsnoop tool
SonarQube的BUG定义
全流程调度——MySQL与Sqoop
Mathematics to solve the problem - circular linked list
CefSharp入门-winform
19.支持向量机-优化目标和大间距直观理解
加密公司向盗窃的黑客提供报价:保留一点,把剩下的归还