1

I have a WinForms application where one of the controls is set to a specific size. 800x600. There is a function to screenshot the control that relies on the on screen size being the same as what is returned in code.

On one of my test machines, it renders fine. The correct size, everything works. On another machine, it renders at 1.25 times the size. In code if I use Control.ClientSize I get 800x600, whereas using an external tool (ShareX, which shows window sizes) it reads as 1000x750. This is reflected in the screenshots, where a large portion of the image is cut off. I know this is down to the DPI scaling, since both machines are outputting 1920x1080 resolution, but the secondary machine has a scaling of 125% vs the primary which is at 100%. As well, if I adjust the scaling down to 100%, the code runs as expected.

My question is then, is there a way to either force the form to render at the desired size (with the control at 800x600, and yes I have tried AutoScaleMode = AutoScaleMode.Dpi), or have a method that will return the actual true size of the control when scaling is accounted for?

Kolya Venturi
  • 41
  • 2
  • 7
  • 1
    One of the answer of [this](http://stackoverflow.com/questions/5977445/how-to-get-windows-display-settings) question might or might not fit – Martheen Dec 13 '16 at 02:17
  • Usually, you should scale the graphic too... Obviously, if you want the form to be a specific size, then you are not using auto-scaling. I would avoid that except maybe for a splash screen and even then given the fact that some device can have a scaling of 2 or event more, you don't really want a very small image on those devices. – Phil1970 Dec 13 '16 at 02:30
  • Do You want to run the application as DPI Unaware or DPI Aware? – Antonín Lejsek Dec 13 '16 at 02:59

0 Answers0