- 1 year ago
How to make the cefwindow not appear on the top and activate it when calling CefWindow::Show?(cef3)
To make the CefWindow
not appear on top and activate it when calling CefWindow::Show
in the Chromium Embedded Framework (CEF3), you can use the following code:
scssCefWindowInfo windowInfo;
windowInfo.SetAsPopup(NULL, "My CEF Window");
CefBrowserSettings browserSettings;
// Create a new CEF browser window
CefRefPtr<CefBrowser> browser = CefBrowserHost::CreateBrowserSync(windowInfo, this, url, browserSettings, NULL);
// Get the CEF browser window handle
HWND browserHwnd = browser->GetHost()->GetWindowHandle();
// Set the window style to not be on top
DWORD windowStyle = GetWindowLong(browserHwnd, GWL_EXSTYLE);
SetWindowLong(browserHwnd, GWL_EXSTYLE, windowStyle & ~WS_EX_TOPMOST);
// Activate the window
SetForegroundWindow(browserHwnd);
// Show the window
ShowWindow(browserHwnd, SW_SHOW);
This code creates a new CefWindow
using CefWindowInfo
and CefBrowserSettings
, and then gets the handle of the resulting browser window using CefBrowserHost::GetWindowHandle
. It then sets the window style to not be on top by modifying the WS_EX_TOPMOST
flag in the window's extended style using SetWindowLong
, and activates the window using SetForegroundWindow
. Finally, it shows the window using ShowWindow
.
Note that this code assumes that you are using a synchronous browser creation method (CreateBrowserSync
) and that this
is a valid CefClient
instance. If you are using an asynchronous browser creation method (CreateBrowser
) or a different client implementation, you may need to modify the code accordingly.