Two Screens Can Different ZoomLevel For Each CefBrowser

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Two Screens Can Different ZoomLevel For Each CefBrowser

Postby ShenQing » Sun Jul 24, 2022 9:16 pm

Hi guys, I have got a difficult problem, in my scene there are two screens with diffent resolution, one screen A is 1920*1080, the other screen B is 3840*2160. I use cef3 to create one CefBrowser A to display page in screen A and setZoomLevel 100%, it shows everything ok, then i popup another window(create another CefBrowser B) in screen B and setZoomLevel 200%, but it will also effect the CefBrowser A in screen A to zoomLevel 200%, it shows CefBrowser A and B shared the same CefBrowserHost, can anyone help me? I just want to display page with different zoomLevel for each cefBrowser,thans! codes show below:

bool ktChrome::onBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& target_url, const CefString& target_frame_name, WindowOpenDisposition target_disposition, bool user_gesture
, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings, CefRefPtr<CefDictionaryValue>& extra_info, bool* no_javascript_access)
{
QString targetUrl = QString::fromStdWString(target_url.ToWString()).toLower();
QString screenID = targetUrl.contains("screenid=02") ? SCREEN_GISSCR
: targetUrl.contains("screenid=03") ? SCREEN_EXTSCR
: targetUrl.contains("screenid=04") ? SCREEN_ADDSCR : SCREEN_DEFSCR;
if (g_ComConfig.m_ScreenSrcMap.contains(screenID))
{
ScreenInfo screen = g_ComConfig.m_ScreenSrcMap[screenID];
windowInfo.bounds.x = screen.RectArea.x();
windowInfo.bounds.y = screen.RectArea.y();
windowInfo.bounds.width = screen.RectArea.width();
windowInfo.bounds.height = screen.RectArea.height();
}

if (g_ComConfig.m_Windowless)
{
windowInfo.style = WS_VISIBLE | WS_POPUP;
}

extra_info = CefDictionaryValue::Create();
extra_info->SetString(SCREEN_SCRID, screenID.toStdWString());

CefBrowserHost::CreateBrowser(windowInfo, client, target_url, settings, extra_info, nullptr);

return true;
}
ShenQing
Newbie
 
Posts: 4
Joined: Tue May 11, 2021 7:04 am

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 195 guests