title: Chromium Embedded (CEF3). How to resize new browser window?
body: <p>So i'm using CEF v3.1180.823 and i'm trying to make browser with multiple tabs.</p>
  
  <p>For every new tab i'm: </p>
  
  <p>1) creating a new window with style WS_POPUPWINDOW.</p>
  
  <pre><code>HWND hWndTab = CreateWindowEx(NULL, w.lpszClassName, 0,
      WS_POPUPWINDOW, x, y, width, height, 
      NULL, NULL, hInst, NULL);
  </code></pre>
  
  <p>2) creating a new "g_handler"</p>
  
  <pre><code>CefRefPtr&lt;ClientHandler&gt; cef_hTab = new ClientHandler();
  </code></pre>
  
  <p>3) creating new browser</p>
  
  <pre><code>CefBrowserHost::CreateBrowser(info, cef_hTab.get(), _url, settings);
  </code></pre>
  
  <p>4) setting this window as child for first (main) tab that never closes</p>
  
  <pre><code>SetParent(hWndTab, g_handler-&gt;GetMainHwnd());
  </code></pre>
  
  <p>5) Setting the HWND of new window as main HWND for new handler</p>
  
  <pre><code>cef_hTab-&gt;SetMainHwnd(hWndTab);
  </code></pre>
  
  <p><strong>My problem is</strong>: how do i resize all of my tabs when main window is resizing?</p>
  
  <p>The default window procedure (i.e. procedure of main tab) has this code:</p>
  
  <pre><code>case WM_SIZE:
          // Minimizing resizes the window to 0x0 
          // which causes our layout to go all
          // screwy, so we just ignore it.
          if (wParam != SIZE_MINIMIZED &amp;&amp; 
              g_handler.get() &amp;&amp; 
              g_handler-&gt;GetBrowser()) 
          {
              CefWindowHandle hwnd = 
                  g_handler-&gt;GetBrowser()-&gt;GetHost()-&gt;GetWindowHandle();
              if (hwnd) 
              {
                  // Resize the browser window and 
                  // address bar to match the new frame
                  // window size
                  RECT rect;
                  GetClientRect(hWnd, &amp;rect);
  
                  rect.top += URLBAR_HEIGHT;
  
                  int urloffset = rect.left + BUTTON_WIDTH * 4;
  
                  HDWP hdwp = BeginDeferWindowPos(1);
                  hdwp = DeferWindowPos(hdwp, hwnd, NULL, rect.left, rect.top, 
                      rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER);
                  EndDeferWindowPos(hdwp);
              }
          }
          break;
  </code></pre>
  
  <p>I have a std::list of my tabs:</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;list&gt;
  #include "include/cef_app.h"
  #include "cefclient/binding_test.h"
  
  using namespace std;
  
  struct STab
  {
      HWND                        hWndTab;
      HWND                        hWndTabButton;
      CefRefPtr&lt;ClientHandler&gt;    cef_handler;
  
      void Destroy();
  };
  
  typedef list&lt;STab&gt; LTabs;
  
  LTabs* GetTabs();
  </code></pre>
  
  <p>And i'm trying to edit the main window procedure like this:</p>
  
  <pre><code>case WM_SIZE:
          if (wParam != SIZE_MINIMIZED &amp;&amp; 
              g_handler.get() &amp;&amp; 
              g_handler-&gt;GetBrowser()) 
          {
              CefWindowHandle hwnd = 
                  g_handler-&gt;GetBrowser()-&gt;GetHost()-&gt;GetWindowHandle();
              if (hwnd) 
              {
                  RECT rect;
                  GetClientRect(hWnd, &amp;rect);
  
                  rect.top += URLBAR_HEIGHT;
  
                  int urloffset = rect.left + BUTTON_WIDTH * 4;
  
                  HDWP hdwp = BeginDeferWindowPos(1);
                  hdwp = DeferWindowPos(hdwp, hwnd, NULL, rect.left, rect.top, 
                      rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER);
                  // added:
                  //------------------------------------------------------------------
                  LTabs* lTabs = GetTabs();
                  LTabs::iterator it;
                  for (it = lTabs-&gt;begin(); it != lTabs-&gt;end(); ++it)
                  {
                      CefWindowHandle hWndTab = 
                          it-&gt;cef_handler-&gt;GetBrowser()-&gt;GetHost()-&gt;GetWindowHandle();
                      if (hWndTab)
                          hdwp = DeferWindowPos(hdwp, hWndTab, NULL, 
                              rect.left, rect.top, rect.right - rect.left, 
                              rect.bottom - rect.top, SWP_NOZORDER);                      
                  }
                  //------------------------------------------------------------------
                  EndDeferWindowPos(hdwp);
              }
          }
          break;
  </code></pre>
  
  <p>But on resizing main window it resizes neither main tab nor my custom tabs.</p>
  
  <p>What am i doing wrong?</p>