Window shape scaling in C #

Is there an easy way to set the zoom level for a Windows form in C #? VBA had the property of scaling a form.

+4
source share
3 answers

There is no way (what I know) to do what you ask with typical WinForms.

If you are doing regular drawing / drawing, you can zoom in using the zoom transform, but as far as I know, for the form all over the world is .NET and the native Windows / C ++ API.

Perhaps you could create something yourself so that you scale the controls with a constant factor. And you can probably find third-party controls / surfaces that support this. And who knows what is possible with WPF. But in a typical world, WinForms is not.

0
source

I had the same problem and solved it like this in C #. Code Continues Form Download

float scaleX = ((float)Screen.PrimaryScreen.WorkingArea.Width / 1024); float scaleY = ((float)Screen.PrimaryScreen.WorkingArea.Height / 768); SizeF aSf = new SizeF(scaleX, scaleY); this.Scale(aSf); 

This "more or less" form of scales and all children. Cycles forever in 800x600 (?) You must set the following form properties:

 AutoscaleMode = Font AutoSize = False 
+8
source

You can get some scale by assigning the Font form, all controls will be enlarged accordingly, if the Autoscale parameter is set to Font. In addition, the Auto Scale settings in False will keep the form size unchanged, the controls will grow to the center of the form. You need to properly configure all the anchors and check the appearance, as this is just a β€œzoom view”.

So basically there is an example constructor here:

 public Form1() { InitializeComponent(); AutoSize = false; AutoScaleMode = AutoScaleMode.Font; Font = new Font("Trebuchet MS", 10.0f, FontStyle.Regular, GraphicsUnit.Point, ((byte)(204)) ); } 

After the form has been shown, assigning a new font will ruin all the controls, and this trick will not work.

+2
source

Source: https://habr.com/ru/post/1276491/


All Articles