Search code examples
c++chromium

Creating two or more CEF browser windows


I have been suffering for two weeks, please help me:

And I use the built-in CEF example - "cefsimple" - it works fine: https://bitbucket.org/chromiumembedded/cef/src/master/tests/cefsimple/?at=master

The "cefsimple" example creates a browser window and opens the specified URL in it.

But as soon as I add another browser window creation feature:

CefBrowserHost::CreateBrowser(window_info, my_browser_handler_, "google.com", browser_settings, nullptr, nullptr);

That's where the problems happen. The second browser window is being created, BUT a problem occurs - the two created windows seem to blink constantly, as if switching between each other very quickly.

I tried the advice - install:

window_info.ex_style = WS_EX_NOACTIVATE;

But it doesn't help at all.

Maybe someone has created more than one window browser in CEF ? What am I doing wrong ?


Solution

  • I've encounter this problem recently, and this may help you.

    In your native window proc, process WM_SETFOCUS with:

    if (!::GetFocus())
    {
        // set cef focus;
    }
    

    Without call ::GetFocus(), two cef windows will blink constantly.