Setting browser zoom with SetZoomLevel at startup

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.

Setting browser zoom with SetZoomLevel at startup

Postby callum » Thu Apr 06, 2017 5:30 pm

I've read some posts here about setting the browser zoom with SetZoomLevel at startup and the consensus (and my experience) seemed to be that it didn't always work because the browser process was often still being created.

I'm implemented the suggested workaround and repeatedly call SetZoonLevel() in CefLoadHandler::OnLoadingStateChange(..) until the level is set but this doesn't work well because (a) the page changes scale as it loads and (b) each time you browse to a new page, the scale appears to reset to 1:1 and then change back to the level the app called for.

Is there a better way to do this now?
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm

Re: Setting browser zoom with SetZoomLevel at startup

Postby Czarek » Wed Apr 12, 2017 11:52 am

Take a look at example implementation of setting zoom level in phpdesktop project. I am setting zoom level constantly with 50 ms interval and it works perfectly, didn't notice any issues.

Code: Select all
    // We need to check zooming constantly, during loading of pages.
    // If we set zooming to 2.0 for localhost/ and then it navigates
    // to google.com, then the zomming is back at 0.0 and needs to
    // be set again.
    CefPostDelayedTask(
            TID_UI,
            NewCefRunnableFunction(&SetBrowserDpiSettings, cefBrowser),
            50);


Complete source code:
https://github.com/cztomczak/phpdesktop ... re.cpp#L10
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Setting browser zoom with SetZoomLevel at startup

Postby callum » Wed Apr 12, 2017 7:07 pm

Thank you - I'll take a look. That seems very promising.
callum
Expert
 
Posts: 326
Joined: Mon Feb 23, 2015 6:19 pm


Return to Support Forum

Who is online

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