Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "zoom factor" mean in OLECMDID_OPTICAL_ZOOM?

I am using ExecWB() to zoom in/out my WebBrowser control like this:

m_lpBrowser->ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER, &(CComVariant)zoomFactor, NULL);

This works just fine when my OS dpi is 100% (96 dpi). However, under OS dpi 150% (144 dpi), setting zoom factor as 100 makes the web page in the browser look much smaller.(I was expecting to get exactly the same layout as the one under OS dpi 100%)

Then I found an old IE8 document.

In this document, OLECMDID_OPTICAL_ZOOM is said to be setting the ZOOM FACTOR of the browser ( ZOOM FACTOR = System DPI / Layout DPI)

But I just can't figure out the meaning of Layout DPI. Is this the root cause that I get smaller web pages?

like image 787
Roger Huang Avatar asked Sep 20 '25 12:09

Roger Huang


1 Answers

This MSDN document mentioned there is a flag DOCHOSTUIFLAG_DPI_AWARE controlling the High DPI behaviour of the web control.

When the flag is set during initialization, the web control uses IE8 High DPI behavior; otherwise, it uses IE7 High DPI behaviour by default.

Under IE8 High DPI behaviour, the parameter zoom factor means exactly the scaling percentage of the web page, just like what you see in the IE zoom UI.

However, under IE7 High DPI behaviour, it's a little bit more complicated. Based on my experiment result,

the actual scaling factor = zoom factor / system dpi(%)

For example, under system 120dpi(125%), setting zoom factor 125 result in 1.0x scaling of web pages.

However, there is still something I can't explain: under system 120dpi(125%), I was expecting to get 80% scaling of web pages when I set zoom factor of 100. It turns out that words are 80% of their original size, but the pictures still 100%. Perhaps it is a bug in IE7 zooming.

like image 143
Roger Huang Avatar answered Sep 23 '25 11:09

Roger Huang