使用cefsharp 浏览器放大

时间:2022-12-12 16:59:49

(1)如果浏览器位置有问题,需要设置 Cef.EnableHighDPISupport();

(2)如果要放大浏览器,需要设置  browser.SetZoomLevel(1.25);

        ChromiumWebBrowser webbrowser = new ChromiumWebBrowser(""); 
        private void Form1_Load(object sender, EventArgs e)
        {


            Cef.EnableHighDPISupport();

            this.FormBorderStyle = FormBorderStyle.None;
            this.WindowState = FormWindowState.Maximized;



            string url = System.Configuration.ConfigurationManager.AppSettings["url"];
            webbrowser = new ChromiumWebBrowser(url);

            // Add it to the form and fill it to the form window.
           
            
            webbrowser.Dock = DockStyle.Fill;
            webbrowser.FrameLoadEnd += webbrowser_FrameLoadEnd;
            this.Controls.Add(webbrowser);

  void webbrowser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e)         {

            ChromiumWebBrowser browser = (ChromiumWebBrowser)sender;

            browser.SetZoomLevel(1.25);

                   }