public Form1() { InitializeComponent(); DPI_test(); } public void DPI_test() { //Specify Here the Resolution Y component in which this form is designed //For Example if the Form is Designed at 800 * 600 Resolution then //DesignerHeight=600 int i_StandardHeight = 768; //Specify Here the Resolution X component in which this form is designed //For Example if the Form is Designed at 800 * 600 Resolution then //DesignerWidth=800 int i_StandardWidth = 1366; int i_PresentHeight = Screen.PrimaryScreen.Bounds.Height; //Present Resolution Height int i_PresentWidth = Screen.PrimaryScreen.Bounds.Width; //Presnet Resolution Width f_HeightRatio = (float)((float)i_PresentHeight / (float)i_StandardHeight); f_WidthRatio = (float)((float)i_PresentWidth / (float)i_StandardWidth); this.AutoScaleMode = AutoScaleMode.None;//Make the Autoscale Mode=None this.Scale(new SizeF(f_WidthRatio, f_HeightRatio)); foreach (Control c in this.Controls) { get_all_controls(c); } foreach (Control c in All_controls) { c.Scale(new SizeF(f_WidthRatio, f_HeightRatio)); c.Font = new Font(c.Font.FontFamily, c.Font.Size * f_HeightRatio, c.Font.Style, c.Font.Unit, ((byte)(0))); } } public void get_all_controls(Control control) { c_all.Add(control.Name); All_controls.Add(control); foreach (Control child in control.Controls) { get_all_controls(child); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)