Page 1 of 1

Creating a Frameless (No Title Bar) Window

PostPosted: Sun Oct 18, 2020 5:31 pm
by ingrown
Hello,

I'm having trouble making a frameless/ window with no title bar. Digging around the forums I tried returning false in cef_window_delegate.h's IsFrameless and I tried launching the demo program with: cefclient.exe --use-views --hide-frame --hide-controls, both to no avail.

Any help would be greatly appreciated. :)

Re: Creating a Frameless (No Title Bar) Window

PostPosted: Mon Oct 19, 2020 10:39 am
by magreenblatt
What OS and CEF version?

Re: Creating a Frameless (No Title Bar) Window

PostPosted: Mon Oct 19, 2020 7:47 pm
by ingrown
Thank you for your response!
I'm using CEF 86.0.17 from Spotify's automated build. I've only tried on Windows so far but digging through the forums shows CEF's Views can accomplish Windows and Linux with the same code.

Re: Creating a Frameless (No Title Bar) Window

PostPosted: Mon Nov 02, 2020 4:16 pm
by tech5678
I just did a quick test in VB.NET, Visual Studio 2017 and it worked perfect, if I'm understanding your intention. Should work identical in C# targeting .NET Framework, but I dunno about Core, WPF or anything else. All I did was:

1. In my original browser app, add a new form ("Form2")
2. Change the form's FormBorderStyle to None
3. Put a panel in it ("panBrowser")
4. Set panel Dock to Fill.
5. Make a tiny code tweak in my original code, calling Form2 instead of the original Form1:

Code: Select all
Imports CefSharp.WinForms
Imports CefSharp
Imports System.IO

Module CEFbrowser

    Public WithEvents browser As ChromiumWebBrowser
    Public CEFPath As String = ""
    Dim settings As New CefSettings()

    Sub LoadCEFBrowser()
        CEFPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\MyBrowserTemp"

        If Not Directory.Exists(CEFPath) Then
            Try
                Directory.CreateDirectory(CEFPath)
            Catch ex As Exception
                MsgBox("Error creating cache directory" + vbCrLf + CEFPath,, "Error")
            End Try
        End If

        settings.CachePath = CEFPath

        'CefSharpSettings.Proxy = new ProxyOptions(ip: "myipaddress", port: "myport", username: "myusername", password: "mypassword")

        browser = New ChromiumWebBrowser("")

        Dim requestContextSettings As New RequestContextSettings()
        requestContextSettings.CachePath = CEFPath
        requestContextSettings.PersistSessionCookies = True

        browser.RequestContext = New RequestContext(requestContextSettings)

        browser.Dock = DockStyle.Fill
        If CefSharp.Cef.IsInitialized = False Then
            CefSharp.Cef.Initialize(settings)
        End If

        Form2.panBrowser.Controls.Add(browser)
        Form2.Show()

    End Sub


Note that due to eliminating the title bar, you'll have to add extra mechanisms to allow the window to be moved etc.