How to maximize the cefsimple window

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.

How to maximize the cefsimple window

Postby susinda » Tue Feb 17, 2015 2:32 am

Hi All

I tried to maximize the cefsimple window by setting width height like follows, but it does not work.
window_info.height = 1080;
window_info.width = 1920;
window_info.SetAsPopup(NULL, "cefsimple");

Any idea? Or any other methods like setting some flag to maximize. Note that im using vs 2010 cefsimple sample app.

Thanks
susinda
Newbie
 
Posts: 2
Joined: Mon Feb 16, 2015 8:26 am

Re: How to maximize the cefsimple window

Postby magreenblatt » Tue Feb 17, 2015 12:42 pm

Here is an example of changing window size on Windows: https://code.google.com/p/chromiumembed ... est_win.cc
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: How to maximize the cefsimple window

Postby susinda » Fri Feb 20, 2015 1:47 am

HI magreenblatt

Many thanks for the answer. It worked.

This is for others who may want the same.
Calling Maximize(browser); in the OnAfterCreated(CefRefPtr<CefBrowser> browser) method worked for me.

Additionally i had to add following 3 methods copied from https://code.google.com/p/chromiumembed ... est_win.cc

HWND GetRootHwnd(CefRefPtr<CefBrowser> browser) {
return ::GetAncestor(browser->GetHost()->GetWindowHandle(), GA_ROOT);
}

// Toggles the current display state.
void Toggle(HWND root_hwnd, UINT nCmdShow) {
// Retrieve current window placement information.
WINDOWPLACEMENT placement;
::GetWindowPlacement(root_hwnd, &placement);

if (placement.showCmd == nCmdShow)
::ShowWindow(root_hwnd, SW_RESTORE);
else
::ShowWindow(root_hwnd, nCmdShow);
}

void Maximize(CefRefPtr<CefBrowser> browser) {
Toggle(GetRootHwnd(browser), SW_MAXIMIZE);
}


Thanks
susinda
Newbie
 
Posts: 2
Joined: Mon Feb 16, 2015 8:26 am

Re: How to maximize the cefsimple window

Postby sancelot » Wed Sep 27, 2017 1:47 am

Hi,
using a linux version, you can set a size to the window using this code too in OnAfterCreated(CefRefPtr<CefBrowser> browser) method .

Code: Select all

  // resize window
  XResizeWindow(cef_get_xdisplay(),browser->GetHost()->GetWindowHandle(),newWidth,newHeight);





However, the window content seems being already displayed and then does not fit the new size.

So, I suppose that I must resize it in another method, but which one or force a content layout refresh ?????


Note: if you want to Maximize, instead of setting a predefined size, you have to retrieve the parent root size and set it as the new size....


Regards
Steph
sancelot
Newbie
 
Posts: 7
Joined: Fri Sep 22, 2017 9:01 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 46 guests