Zoom on initialise

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Zoom on initialise

Postby samgplay » Mon Apr 04, 2016 8:43 am

HI all,
Does anyone have or know the solution to the following issue,

I set the zoom level of the web browser as its initialised but the zoom level doesn't seem to do anything. is there another way to set the zoom level as the page is loaded as so far the only way i can get this to work is by having a timer wait for several seconds then setting the zoom level.

webBrowser.IsBrowserInitializedChanged += WebBrowserOnIsBrowserInitializedChanged;



private void WebBrowserOnIsBrowserInitializedChanged(object sender, IsBrowserInitializedChangedEventArgs isBrowserInitializedChangedEventArgs)
{
ChromiumWebBrowser webBrowser = (ChromiumWebBrowser)sender;

if (webBrowser.IsBrowserInitialized)
{
webBrowser.SetZoomLevel(-2.0);
}
}

this code runs but the set zoom level method does nothing
samgplay
Newbie
 
Posts: 2
Joined: Mon Apr 04, 2016 8:31 am

Re: Zoom on initialise

Postby samgplay » Tue Apr 05, 2016 4:22 am

I have found the solution to this. instead of using the on initialized event I instead used the web browsers loading state changed event and checked inside here if the page has finished loading.

webBrowser.LoadingStateChanged += WebBrowserOnLoadingStateChanged;

private void WebBrowserOnLoadingStateChanged(object sender, LoadingStateChangedEventArgs loadingStateChangedEventArgs)
{
ChromiumWebBrowser web = (ChromiumWebBrowser)sender;
if (!web.IsLoading)
{
web.SetZoomLevel(Zoom);
}
}

This seems to work for what i needed
samgplay
Newbie
 
Posts: 2
Joined: Mon Apr 04, 2016 8:31 am


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 16 guests