1
votes

I am making an application and trying to get my controls to be the same (physical, in cm, inches,...) size even showed when showed on different screens (using differnt resolutions, dpi). I tried scaling by DPI in winforms. It scales the controls to what it thinks to be the same size, but it is infact off.

What is the best way to get controls to be the same physical sizes on different screens in c#. I prefer winforms but WPF is fine too.

2
I'd say use the Panels Control in combination with Docking in WinForms, and for WPF try reading through this tutorial: wpftutorial.net/LayoutProperties.Yves Schelpe
i'm looking for controls that are 1cm on one screen to be one 1cm on another screen aswell. Not a basic layoutRazorEater
Ok, I understand. I'd go with WPF then. The properties height & width should accept cm-based parameters I think. EDIT: see answer of +ArsenMkrt below.Yves Schelpe
To do what you're asking, Windows would need to know what size your monitor is, and it doesn't. There's no place in Control Panel where you can tell it whether you're using an ancient 15" CRT, a 27" LCD, a 60" high-def TV, or a projector (where the physical size depends on how far the projector is from the wall, another thing Windows can't possibly know). I've long thought their "DPI" terminology was terribly misleading, because it doesn't tie back to actual inches in any way. In some cases it might be a rough approximation, but that's all you get.Joe White
the rough approximation is what i'll have to work with, i just found that out myself. what i do now in WPF is get the system DPI and divide it by 96 (DIU) to get a factor. I enlarge my controls by this factor. For some reason i'm not gonna look into this does not work with winforms.RazorEater

2 Answers

0
votes

In WPF it is simple

<Window ... Height="10cm" Width="20cm"> </Window>
0
votes

I have the same requirements a while ago and the direction I decided to go is a combination of C++ and C#/WPF.

Please feel free to send in any comment.