WinForms returns different scale factor values for Width and Height

603 views Asked by At

I have a .NET WinForms dialog and I am using the AutoScaleFactor property of the Form in Form_Resize event to get the scale factor. If I set the scaling to 200% (for my 1920x1080 resolution), the scale factor should be Width=2,Height=2 but it comes as Width=2,Height=1.923077 and this causes a minor difference in the pixel calculation.

Why is it returning two different values? Isn't it suppose to return the same value for both Width and Height?

I have an embedded IE Browser control and I calculate the scale values through JavaScript using the following code:

var scaleFactorX = screen.deviceXDPI / screen.logicalXDPI;
var scaleFactorY = screen.deviceYDPI / screen.logicalYDPI;
alert('ScaleFactor X=' + scaleFactorX + ', Y=' + scaleFactorY);
    

then it displays Width=2,Height=2

0

There are 0 answers