Launching Cef in fullscreen mode

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Re: Launching Cef in fullscreen mode

Postby HarmlessDave » Wed Jun 21, 2017 11:05 am

Is this C++ or C#? Windows or something else? The file I pointed to showed setting the Windows window style. You change the style bits to not show a title bar.
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Launching Cef in fullscreen mode

Postby sburke » Wed Jun 21, 2017 11:27 am

The application that I have authored to wrap Cef is C#. However, the Chromium source code is all C++, as you are probably aware. When I build Cef it generates two executables: cefsimple.exe and cefclient.exe. I have succeeded in getting cefclient.exe to launch maximized, but it still includes the window frame and toolbar. What I need is for it to launch with only the content visible and maximized, just as if a user pressed F11 in Chrome.

If I can get the browser to launch in true fullscreen mode then I should be able to embed it in my C# wrapper and manipulate dimensions and location by setting coordinates and dimensions on the parent dialog.
sburke
Mentor
 
Posts: 54
Joined: Tue May 30, 2017 1:17 pm

Re: Launching Cef in fullscreen mode

Postby sburke » Mon Jul 03, 2017 9:22 am

Solved this one by posting messages across to the browser from the C# wrapper. For anybody else who needs to do this, see below. This assumes that the handle to the wrapper dialog is stored in hwndThisForm:

Code: Select all
Process cefProc = new Process();
string strURL = "www.google.com";
cefProc = System.Diagnostics.Process.Start(".\\Cef\\cefsimple.exe", string.Format("--url={0}", strURL));

if ((hwndThisForm != IntPtr.Zero) && (cefProc.Handle != IntPtr.Zero))
{
  Rect thisRect = new Rect();
  GetWindowRect(hwndThisForm, ref thisRect);

  SetParent(cefProc.Handle, this.Handle);

  int style = GetWindowLong(cefProc.Handle, GWL_STYLE);
  SetWindowLong(cefProc.Handle, GWL_STYLE, (style & ~WS_CAPTION));

  SetWindowPos(cefProc.Handle,
               0,
               0,
               0,
               Screen.PrimaryScreen.Bounds.Width,
               Screen.PrimaryScreen.Bounds.Height,
               SWP.SHOWWINDOW);
}
sburke
Mentor
 
Posts: 54
Joined: Tue May 30, 2017 1:17 pm

Re: Launching Cef in fullscreen mode

Postby Wolf » Fri Jun 29, 2018 5:32 am

I use a different approach, i simply send a Window System Message to the Browser Window to maximize itself, after it is created. I do this only if it is the first browser window.
Maybe it helps, even the post is older ;)
void SimpleHandler::OnAfterCreated(CefRefPtr<CefBrowser> browser) {
CEF_REQUIRE_UI_THREAD();

// Add to the list of existing browsers.
browser_list_.push_back(browser);

if (browser_list_.size() == 1) {
CefWindowHandle hWnd = browser->GetHost()->GetWindowHandle();
::SendMessage(hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
}
}
Wolf
Newbie
 
Posts: 1
Joined: Fri Jun 29, 2018 5:18 am

Re: Launching Cef in fullscreen mode

Postby jimmycaojp » Thu Aug 09, 2018 8:39 pm

try this in windows
CefWindowInfo window_info;
HDC hDC = ::GetWindowDC(NULL);
window_info.width = ::GetDeviceCaps(hDC, HORZRES);
window_info.height = ::GetDeviceCaps(hDC, VERTRES);

and set window style: style = WS_POPUPWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE; //before create window
// Create the first browser window.
CefBrowserHost::CreateBrowser(window_info, handler, url, browser_settings,
NULL);
and in linux gtk+ , like this:
// let it maxsize
GdkScreen *gdk_screen;
gint screen_width, screen_height;

gdk_screen = gdk_screen_get_default();

screen_width = gdk_screen_get_width(gdk_screen);
screen_height= gdk_screen_get_height(gdk_screen);

// make it no title bar
window_ = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_decorated(GTK_WINDOW(window_),false); // no title bar
jimmycaojp
Newbie
 
Posts: 5
Joined: Mon Jul 30, 2018 3:14 am

Previous

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 37 guests