Method for resize/repositioning existing browser area

Think CEF could benefit from a new feature or capability? Discuss CEF feature requests here.

Method for resize/repositioning existing browser area

Postby DarthCoder » Mon Sep 19, 2011 3:03 am

How about providing a method to resize/reposition an existing browser area (WebViewHost) on a parent window. I am referring to the case where the browser area is created as a child rather than as a popup.

In the sample CefClient app, its currently done in response to the WM_SIZE message using the following code.

Code: Select all
// Resize the browser window and address bar to match the new frame
// window size
RECT rect;
GetClientRect(hWnd, &rect);
rect.top += URLBAR_HEIGHT;

int urloffset = rect.left + BUTTON_WIDTH * 4;

HDWP hdwp = BeginDeferWindowPos(1);
hdwp = DeferWindowPos(hdwp, editWnd, NULL, urloffset,
          0, rect.right - urloffset, URLBAR_HEIGHT, SWP_NOZORDER);
hdwp = DeferWindowPos(hdwp, g_handler->GetBrowserHwnd(), NULL,
          rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
          SWP_NOZORDER);
EndDeferWindowPos(hdwp);


While this is for the case when we are resizing the parent window and want the child windows to be resized as well, there are use cases where an embedder may want to resize or reposition the browser area at any time based on business logic.

A simple Cef method (probably something like CefClient::SetPositionAndSize)to warp this functionality would be nice and convenient.
DarthCoder
Techie
 
Posts: 23
Joined: Mon Jun 20, 2011 4:57 am

Re: Method for resize/repositioning existing browser area

Postby magreenblatt » Mon Sep 19, 2011 6:25 pm

I think it's better to use the OS API functions for this. You can retrieve the window handle by calling CefBrowser::GetWindowHandle(). It's up to the application to determine if SetWindowPos() or DeferWindowPos() is more appropriate.
magreenblatt
Site Admin
 
Posts: 12383
Joined: Fri May 29, 2009 6:57 pm


Return to Feature Request Forum

Who is online

Users browsing this forum: No registered users and 15 guests