When creating an application in VS, Windows, the form has a size that is clearly defined (for example, 1600x800). When launched, it changes its size a lot. It turns out that the real size of the window is somewhere around 800x400. In the program, it is necessary to orient objects on the form along certain coordinates, and they change randomly. How to make the form have a stable size regardless of the screen resolution? Or how to set the size of the form in physical size (inches, centimeters), and not in pixels c#?
Asked
Active
Viewed 401 times
0
-
Does this answer your question? [Winforms different sizes in different environments](https://stackoverflow.com/questions/12123073/winforms-different-sizes-in-different-environments) and [C# windows form - Is it possible to programmatically determine text size through the metric system? If so, how?](https://stackoverflow.com/questions/44807870/c-sharp-windows-form-is-it-possible-to-programmatically-determine-text-size-th) and [Size windows form in inches](https://stackoverflow.com/questions/45103094/size-windows-form-in-inches) – May 15 '21 at 14:37
-
First thing, you need to design at 100% scale. Visual Studio shows a notification when you don't. Then, your application must be DpiAware. If it's not, the System will virtualize its dimensions and you also cannot read either its real size or the actual Dpi of the Screens. -- When you can finally read real values, you can then set the size of your Forms to any measure, it's just a conversion of values. – Jimi May 15 '21 at 16:26
-
Start from here: [How to configure an app to run correctly on a machine with a high DPI setting (e.g. 150%)?](https://stackoverflow.com/a/13228495/7444103) if your app is not DpiAware yet. Enhance with: [High DPI support in Windows Forms](https://learn.microsoft.com/en-us/dotnet/desktop/winforms/high-dpi-support-in-windows-forms) (see also the rest of the documentation, on the left: the Automatic Scaling section and related parts). -- Yes, it requires quite a lot of testing. – Jimi May 15 '21 at 16:30