visual c++ - Chromium Embedded (CEF3). How to resize new browser window? -


so i'm using cef v3.1180.823 , i'm trying make browser multiple tabs.

for every new tab i'm:

1) creating new window style ws_popupwindow.

hwnd hwndtab = createwindowex(null, w.lpszclassname, 0,     ws_popupwindow, x, y, width, height,      null, null, hinst, null); 

2) creating new "g_handler"

cefrefptr<clienthandler> cef_htab = new clienthandler(); 

3) creating new browser

cefbrowserhost::createbrowser(info, cef_htab.get(), _url, settings); 

4) setting window child first (main) tab never closes

setparent(hwndtab, g_handler->getmainhwnd()); 

5) setting hwnd of new window main hwnd new handler

cef_htab->setmainhwnd(hwndtab); 

my problem is: how resize of tabs when main window resizing?

the default window procedure (i.e. procedure of main tab) has code:

case wm_size:         // minimizing resizes window 0x0          // causes our layout go         // screwy, ignore it.         if (wparam != size_minimized &&              g_handler.get() &&              g_handler->getbrowser())          {             cefwindowhandle hwnd =                  g_handler->getbrowser()->gethost()->getwindowhandle();             if (hwnd)              {                 // resize browser window ,                  // address bar match 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, hwnd, null, rect.left, rect.top,                      rect.right - rect.left, rect.bottom - rect.top, swp_nozorder);                 enddeferwindowpos(hdwp);             }         }         break; 

i have std::list of tabs:

#include <vector> #include <list> #include "include/cef_app.h" #include "cefclient/binding_test.h"  using namespace std;  struct stab {     hwnd                        hwndtab;     hwnd                        hwndtabbutton;     cefrefptr<clienthandler>    cef_handler;      void destroy(); };  typedef list<stab> ltabs;  ltabs* gettabs(); 

and i'm trying edit main window procedure this:

case wm_size:         if (wparam != size_minimized &&              g_handler.get() &&              g_handler->getbrowser())          {             cefwindowhandle hwnd =                  g_handler->getbrowser()->gethost()->getwindowhandle();             if (hwnd)              {                 rect rect;                 getclientrect(hwnd, &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;                 (it = ltabs->begin(); != ltabs->end(); ++it)                 {                     cefwindowhandle hwndtab =                          it->cef_handler->getbrowser()->gethost()->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; 

but on resizing main window resizes neither main tab nor custom tabs.

what doing wrong?

quick solution use setwindowpos function instead of deferwindowpos function.

//hdwp = deferwindowpos(hdwp, hwndtab, null,  //                      rect.left, rect.top, rect.right - rect.left,  //                      rect.bottom - rect.top, swp_nozorder); setwindowpos(hwndtab, null, rect.left, rect.top,               rect.right - rect.left, rect.bottom - rect.top,               swp_nomove|swp_nozorder|swp_noactivate); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -