简体   繁体   English

CefSharp.WinForms "Dock =DockStyle.Fill" 没效果,黑边。如何让ChromiumWebBrowser填充TBForm?

[英]CefSharp.WinForms "Dock =DockStyle.Fill" no effect, black edge.how to make the ChromiumWebBrowser fill the TBForm?

public partial class TBForm : Form
{
    private readonly ChromiumWebBrowser browser;

    public TBForm()
    {
        InitializeComponent();

        browser = new ChromiumWebBrowser("www.baidu.com")
        {
            Dock = DockStyle.Fill,
        };

        this.Controls.Add(browser);
    }
}

i got this result我得到了这个结果

CefSharp.WinForms "Dock =DockStyle.Fill" no effect, black edge. CefSharp.WinForms "Dock =DockStyle.Fill" 没有效果,黑边。

how to make the ChromiumWebBrowser fill the TBForm?如何让 ChromiumWebBrowser 填充 TBForm?

Do you tried disable the GPU engine using CefCommandLineArgs?您是否尝试过使用 CefCommandLineArgs 禁用 GPU 引擎?

When you declare:当您声明:

CefSettings settings = new CefSettings();

before initializations:初始化前:

Cef.Initialize(settings);

Try to add the nex line of code:尝试添加下一行代码:

settings.CefCommandLineArgs.Add("disable-gpu", "1");

My experience was this was caused from using higher DPI settings.我的经验是这是由于使用更高的 DPI 设置造成的。 I used the recommended helper method at the entry point of my application:我在应用程序的入口点使用了推荐的辅助方法:

Cef.EnableHighDPISupport()

See here for more details: https://github.com/cefsharp/CefSharp/wiki/General-Usage#high-dpi-displayssupport有关更多详细信息,请参见此处: https : //github.com/cefsharp/CefSharp/wiki/General-Usage#high-dpi-displayssupport

Your windows screen resolution is not set to 100%.您的 Windows 屏幕分辨率未设置为 100%。 See the image below:见下图:

在此处输入图片说明

This is because CefSharp is using GPU to render and will depend on your screen resolution setting.这是因为 CefSharp 使用 GPU 进行渲染并且将取决于您的屏幕分辨率设置。

using this will fix the rendering to host display highest resolution:使用这将修复渲染到主机显示最高分辨率:

Cef.EnableHighDPISupport();

And this will disable GPU rendering:这将禁用 GPU 渲染:

var settings = new CefSettings();
settings.CefCommandLineArgs.Add("disable-gpu", "1");
Cef.Initialize(settings);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM