CefSharp文档参考https://github.com/cefsharp/CefSharp

使用Winform作为载体
包:CefSharp.WinForms 89.0.170
Framework:net4.8

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.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using System.Windows.Forms;namespace ScreenSlice
{public partial class OnlyOne : Form{private ChromiumWebBrowser c1;private Form1 returnForm1 = null;public OnlyOne(Form1 F1){InitializeComponent(); //FormBorderStyle.None 时候最大化不遮盖任务栏 使得statusStrip得以显示this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);c1 = new ChromiumWebBrowser(CommonHelper.homeUrl);c1.LifeSpanHandler = new OpenPageSelf();c1.MenuHandler = new MenuHandler();panel1.Controls.Add(c1);returnForm1 = F1; }private void OnlyOne_Load(object sender, EventArgs e){string xmlFilePath = Application.StartupPath + @"\Resource\0.config";XmlHelper xH = new XmlHelper(xmlFilePath, "Settings");toolStripTextBox1.Text = xH.ReadSetting("Url1"); InformationDisplay();}private void OnlyOne_FormClosing(object sender, FormClosingEventArgs e){c1.Dispose();c1 = null;returnForm1.Visible = true;}private void toolStripMenuItem1_Click(object sender, EventArgs e){c1.Load("About:Blank");c1.Load(toolStripTextBox1.Text);}private void StartToolStripMenuItem_Click(object sender, EventArgs e){c1.Load(toolStripTextBox1.Text);saveUrl();}public void saveUrl(){string xmlFilePath = Application.StartupPath + @"\Resource\0.config";XmlHelper xH = new XmlHelper(xmlFilePath, "Settings");xH.WriteSetting("Url1", toolStripTextBox1.Text);}private void MinMenuItem1_Click(object sender, EventArgs e){//this.WindowState = FormWindowState.Minimized;if (this.WindowState == FormWindowState.Maximized){ this.WindowState = FormWindowState.Minimized; }  else if(this.WindowState == FormWindowState.Normal) { this.WindowState = FormWindowState.Maximized; }}private void CloseMenuItem_Click(object sender, EventArgs e){this.Close();}#region 状态栏public  void InformationDisplay(){System.Timers.Timer dEvent = new System.Timers.Timer();dEvent.Elapsed += new ElapsedEventHandler(DisplayEvent); dEvent.Interval = 1000;dEvent.Start();}private delegate void RefreshText(string txt);//代理public  void DisplayEvent(object source, ElapsedEventArgs e){try{string tMsg = "";RefreshText rt = new RefreshText(UptSSL1Txt);this.BeginInvoke(rt, tMsg);}catch { return; }}public void UptSSL1Txt(string txt){this.tSSL1.Text = DateTime.Now.ToString()+"  "+txt;}#endregion#region 无边框窗体移动[DllImport("user32.dll")]public static extern bool ReleaseCapture();[DllImport("user32.dll")]public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);public const int WM_SYSCOMMAND = 0x0112;public const int SC_MOVE = 0xF010;public const int HTCAPTION = 0x0002;private void MS_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e){ReleaseCapture();SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);}#endregion}
}

配置

        public static CefSettings cSettings(){var settings = new CefSettings{Locale = "zh-CN",AcceptLanguageList = "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",RemoteDebuggingPort = 8088,//LocalesDirPath = "CHBrowser/localeDir",LogSeverity = LogSeverity.Disable,//LogFile = "CHBrowser/LogData",PersistSessionCookies = true,//Persistent Cookies会被保存在一个浏览器的一个子文件夹中UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36",IgnoreCertificateErrors = true,MultiThreadedMessageLoop = true,//让浏览器的消息循环在一个单独的线程中执行,建议设置成true,具体含义看看浏览器消息处理。WindowlessRenderingEnabled = true,//如果不开启好多用那种JSUI的控件的网站 都有问题CachePath = Application.StartupPath + @"\Cache",//缓存目录};settings.CefCommandLineArgs.Add("disable-application-cache", "1");//不要缓存settings.CefCommandLineArgs.Add("disable-gpu", "1");//去掉gpu,否则chrome显示有问题settings.CefCommandLineArgs.Add("enable-media-stream", "1"); //Enable WebRTCsettings.CefCommandLineArgs.Add("proxy-auto-detect", "0");settings.CefCommandLineArgs.Add("no-proxy-server", "1"); //Don't use a proxy server, always make direct connections. Overrides any other proxy server flags that are passed.//settings.CefCommandLineArgs.Add("debug-plugin-loading", "1"); //Dumps extra logging about plugin loading to the log file.//settings.CefCommandLineArgs.Add("disable-plugins-discovery", "1"); //Disable discovering third-party plugins. Effectively loading only ones shipped with the browser plus third-party ones as specified by --extra-plugin-dir and --load-plugin switchessettings.CefCommandLineArgs.Add("allow-running-insecure-content", "1"); //By default, an https page cannot run JavaScript, CSS or plugins from http URLs. This provides an override to get the old insecure behavior. Only available in 47 and above.//settings.CefCommandLineArgs.Add("ppapi-flash-version", "34.0.0.118"); //设置flash插件版本//string flashFilePath = Application.StartupPath + @"\Plugins\pepflashplayer.dll";//settings.CefCommandLineArgs.Add("ppapi-flash-path", flashFilePath);//settings.CefCommandLineArgs.Add("enable-system-flash", "1");settings.CefCommandLineArgs.Add("enable-npapi", "1");settings.CefCommandLineArgs.Add("ppapi-out-of-process", "1");settings.CefCommandLineArgs.Add("plugin-policy", "allow");// Cookies path//Cef.GetGlobalCookieManager().SetStoragePath(Program.COOKIES_PATH, false);// Create a browser component//webBrowser = new ChromiumWebBrowser("about:blank");//webBrowser.Name = "WebBrowser";//webBrowser.TabIndex = 0;//webBrowser.BrowserSettings.ApplicationCache = CefState.Disabled;//webBrowser.BrowserSettings.FileAccessFromFileUrls = CefState.Enabled;//webBrowser.BrowserSettings.UniversalAccessFromFileUrls = CefState.Enabled;//webBrowser.BrowserSettings.ImageLoading = CefState.Disabled;//webBrowser.BrowserSettings.Javascript = CefState.Enabled;//webBrowser.BrowserSettings.WebSecurity = CefState.Disabled;//webBrowser.KeyboardHandler = new BrowserChrome.KeyboardHandler(); // prevent keyboard//webBrowser.JsDialogHandler = new BrowserChrome.JsHandler(); // prevent alertsreturn settings;}}
}

源码 + 程序
https://download.csdn.net/download/aj54aja/75049121

C#使用 CefSharp 制作一个分屏浏览器相关推荐

  1. 基于vue手写一个分屏器,通过鼠标控制屏幕宽度。

    基于vue手写一个分屏器,通过鼠标控制屏幕宽度. 先来看看实现效果: QQ录屏20220403095856 下面是实现代码: <template><section class=&qu ...

  2. android+制作一个锁屏,手机个性锁屏怎么做?教你如何制作DIY手机锁屏图文教程...

    制作DIY手机个性锁屏的方法很简单,只需下载一款软件即可自定义各种类型的壁纸来当做大家的个性化锁屏,具体教程小编将在本文告诉大家,希望能够帮助到大家.下面就一起来看看本教程吧 教你如何制作DIY手机锁 ...

  3. 制作一个简单的浏览器WebView的使用

    在Android中,要使用内置的浏览器,需要通过WebView组件来实现,核心是开源WebKit引擎. WebView是专门用来浏览网页的,既可以在XML文件中使用<WebView>标记添 ...

  4. 使用C++制作一个蓝屏程序

    大家有没有想过和你的好朋友增加"友情"? 这个蓝屏程序绝对帮得上你! 我也没试过,这是我好朋友送我的,他想把我的电脑当成小白鼠-- 一定要全部复制,否则无法运行! #include ...

  5. 推荐一个分屏软件,spectacle

    在windows下面,我们可以在编码的时候,左边开一半的文档,右边编码,想在MAC上面实现,用上这软件就可以了,官网地址 http://spectacleapp.com

  6. html视频分屏插件,如何制作分屏视频

    如何制作分屏视频? 蜜蜂剪辑 蜜蜂剪辑同样也拥有非常友好的主界面以及强大的编辑功能.这款软件可以帮您制作出一个非常精彩的分屏视频.您可以剪辑或者合并视频.音频设置淡入淡出效果,调整视频的亮度.色调以及 ...

  7. linux分屏显示两个文件内容,在linux中,如何分屏显示一个文件(如.txt)的内容?指令或快捷键...

    linux中如果想要把某个命令或者程序执行的输出结果分屏显示,可以使用more工具来实现.是几乎所有linux发行版都自带的一个分屏显示的工具. 1:如果只是输出一个文件的内容,可以直接用more来输 ...

  8. ipad怎么和mac分屏_ipad学习方法分享[1]

    之前回答了一个考研用ipad方便吗的问题,有很多同学问我具体怎么用ipad学习,正好最近解锁了ipad新技能,就来分享一下. 一.目录:(时间紧的同学可以选择性跳着看) 1.基本情况-我自己用ipad ...

  9. FCPX插件:屏幕分屏特效插件Stupid Raisins Split Pop

    想要为照片或者视频创建分屏效果的朋友可以试试这款FCPX插件:屏幕分屏特效插件Stupid Raisins Split Pop,适用于Final Cut Pro和FxFactory,其中包含41种屏幕 ...

最新文章

  1. 又有多省明确开学时间!哪个省份的高校全国最早开学?
  2. 如何面对自己不喜欢的工作?
  3. 微信小程序修改样式弹框wx.showModal
  4. 你如何检查选择器是否匹配jQuery中的内容? [重复]
  5. Android组件系列----Activity的生命周期
  6. 产品经理其实是一种能力,而非职业
  7. linux php oauth安装,Linux php 扩展安装 mongo ,redis ,soap,imap,pdo_mysql,oauth
  8. 使用 Scrum开发太阳能汽车
  9. Springboot项目结构浅析
  10. 从需求到交付——论敏捷过程中的需求管理
  11. 2020 ccf推荐中文期刊_中国计算机学会推荐中文期刊目录,让业内学者不再盲目投稿...
  12. 丹麦红十字会与多家公司合作推出区块链支持的灾难债券
  13. 在32位的linux平台上为Oracle配置1.7GB的SGA
  14. 共享锁 排他锁 是什么区别
  15. 高效能人士的七个习惯读后感与总结概括-(第五章)
  16. 在java中如何对数组实现添加、删除和插入操作呢?
  17. 怎么去除视频上的文字?一篇教你:视频上的文字水印怎么去除
  18. 谷粒商城微服务分布式基础篇二—— Spring Cloud Alibaba、Nacos注册与发现
  19. Educational Codeforces Round 118 (Rated for Div. 2) C. Poisoned Dagger(二分或搜索)
  20. ALV 下载到EXCEL里出现的问题

热门文章

  1. 当人说君子动口不动手时怎么回怼_如何优雅㨃(duǐ)/怼人既彰显气质又㨃(duǐ)/怼得她无话可说?...
  2. Java中为什么在重写finalize()方法时首选调用super.finalize()?
  3. 海潮改正matlab,OSU提供的读取tpxo7.2海潮模型的matlab使用软件
  4. Redis系列之位图简介
  5. 游戏老玩家告诉你如何3步戒掉游戏瘾
  6. 自定义异常BusinessException:null
  7. python计算营业额计算应缴纳营业税款保留两位小数_全国2009年7月高等教育自学考试中国税制试题...
  8. js 左右滑动切换图片
  9. Monocular Total Capture: Posing Face, Body, and Hands in the Wild ∗
  10. 幼儿园故事导入语案例_幼儿园教学导入语