@@ -44,22 +44,26 @@ namespace {
4444// implementation for the CefWindow that hosts the Views-based browser.
4545class SimpleWindowDelegate : public CefWindowDelegate {
4646 CefRefPtr<CefBrowserView> fBrowserView ;
47- int fWidth {800 }; // /< preferred window width
48- int fHeight {600 }; // /< preferred window height
47+ int fWidth = 800 ; // /< preferred window width
48+ int fHeight = 600 ; // /< preferred window height
49+ bool fBatch = false ;
4950public:
50- explicit SimpleWindowDelegate (CefRefPtr<CefBrowserView> browser_view, int width = 800 , int height = 600 )
51- : fBrowserView(browser_view), fWidth(width), fHeight(height)
51+ explicit SimpleWindowDelegate (CefRefPtr<CefBrowserView> browser_view, int width = 800 , int height = 600 , bool batch = false )
52+ : fBrowserView(browser_view), fWidth(width), fHeight(height), fBatch(batch)
5253 {
5354 }
5455
5556 void OnWindowCreated (CefRefPtr<CefWindow> window) override
5657 {
57- // Add the browser view and show the window.
5858 window->AddChildView (fBrowserView );
59- window->Show ();
6059
61- // Give keyboard focus to the browser view.
62- fBrowserView ->RequestFocus ();
60+ if (fBatch ) {
61+ window->Hide ();
62+ } else {
63+ window->Show ();
64+ // Give keyboard focus to the browser view.
65+ fBrowserView ->RequestFocus ();
66+ }
6367 }
6468
6569 void OnWindowDestroyed (CefRefPtr<CefWindow> window) override { fBrowserView = nullptr ; }
@@ -202,7 +206,7 @@ void SimpleApp::StartWindow(THttpServer *serv, const std::string &addr, const st
202206 CefBrowserView::CreateBrowserView (fGuiHandler , url, browser_settings, nullptr , nullptr , new SimpleBrowserViewDelegate ());
203207
204208 // Create the Window. It will show itself after creation.
205- CefWindow::CreateTopLevelWindow (new SimpleWindowDelegate (browser_view, rect.width , rect.height ));
209+ CefWindow::CreateTopLevelWindow (new SimpleWindowDelegate (browser_view, rect.width , rect.height , is_batch ));
206210
207211 if (fNextHandle ) {
208212 fNextHandle ->SetBrowser (browser_view->GetBrowser ());
@@ -217,13 +221,14 @@ void SimpleApp::StartWindow(THttpServer *serv, const std::string &addr, const st
217221 // one should implement CefRenderHandler
218222
219223 #if defined(OS_WIN)
220- RECT wnd_rect = { rect.x , rect. y , rect. x + rect. width , rect. y + rect. height };
221- if (!rect. IsEmpty ()) window_info.SetAsChild (0 , wnd_rect );
224+ if (! rect.IsEmpty ())
225+ window_info.SetAsChild (0 , rect );
222226 // On Windows we need to specify certain flags that will be passed to
223227 // CreateWindowEx().
224228 window_info.SetAsPopup (0 , " cefsimple" );
225229 if (is_batch)
226- window_info.SetAsWindowless (GetDesktopWindow ());
230+ // window_info.SetAsWindowless(GetDesktopWindow());
231+ window_info.SetAsWindowless (kNullWindowHandle );
227232 #else
228233 if (!rect.IsEmpty ())
229234 window_info.SetAsChild (0 , rect);
0 commit comments