首页 > 解决方案 > 使用 CefSharp 时屏幕闪烁

问题描述

    public Notice() {
        InitializeComponent();

        AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
    }
    private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
    {
        if (args.Name.StartsWith("CefSharp"))
        {
            string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
            string architectureSpecificPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                Environment.Is64BitProcess ? "x64" : "x86",
                assemblyName);

            return File.Exists(architectureSpecificPath)
                ? Assembly.LoadFile(architectureSpecificPath)
                : null;
        }

        return null;
    }

    private void InitChrome()
    {
        Cef.EnableHighDPISupport();

        var settings = new CefSettings()
        {
            BrowserSubprocessPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
                                    Environment.Is64BitProcess ? "x64" : "x86",
                                    "CefSharp.BrowserSubprocess.exe")
        };
        
        if (!Cef.IsInitialized)
            Cef.Initialize(settings);

        chromeBrowser = new ChromiumWebBrowser(page);
        chromeBrowser.RequestHandler = new CustomRequestHandler();
        //chromeBrowser.IsBrowserInitializedChanged += ChromeBrowser_IsBrowserInitializedChanged;
        this.Controls.Add(chromeBrowser);
        chromeBrowser.Dock = DockStyle.Fill;
    }

有一个父窗体和一个 mdi 子窗体。我以子形式使用 ChromiumWebBrowser。当鼠标指针位于父窗体上时,ChromiumWebBrowser 会一直闪烁。我该如何解决这个问题?

标签: c#winformscefsharp

解决方案


推荐阅读