可拖动的无边界窗口CefSharp C#WinForms

时间:2018-10-23 09:17:44

标签: c# html chromium cefsharp

我不知道。 我有无国界表格。我该如何做才能使窗口(按住鼠标)移动一定距离? 抱歉英语不好:)

这不起作用... HTML

.title-area 
{
    -webkit-user-select: none;
    -webkit-app-region: drag;
    -moz-user-select: none;
    user-select: none;  
}
<div class='title-area' style="min-width: 100%; height: 40px; background: red;"></div>

C#

public partial class Form1 : Form
{
    private ChromiumWebBrowser chromeBrowser;

    public Form1()
    {
        InitializeComponent();
        InitializeChromium();
        CefSharpSettings.LegacyJavascriptBindingEnabled = true;
        chromeBrowser.RegisterJsObject("cefCustomObject", new сefCustomObject(chromeBrowser, this));
        chromeBrowser.MenuHandler = new MenuHandler();
    }

    public void InitializeChromium()
    {
        CefSettings settings = new CefSettings();

        String page = string.Format(@"{0}\gui\html\index.html", Application.StartupPath);

        if (!File.Exists(page))
        {
            MessageBox.Show("Error: " + page);
        }

        Cef.Initialize(settings);
        chromeBrowser = new ChromiumWebBrowser(page);
        this.Controls.Add(chromeBrowser);
        chromeBrowser.Dock = DockStyle.Fill;

        BrowserSettings browserSettings = new BrowserSettings();
        browserSettings.FileAccessFromFileUrls = CefState.Enabled;
        browserSettings.UniversalAccessFromFileUrls = CefState.Enabled;
        chromeBrowser.BrowserSettings = browserSettings;
    }
}

0 个答案:

没有答案