本文介绍了c#dpi意识到应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨每一个



我需要在每个屏幕分辨率上构建Windows应用程序工作

现在我正在使用以下代码

Hi every one

I need to build windows application work on every screen resolution
now I am using following code

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);
            }
        }





但这不起作用

我怎么能使我的应用程序具有相同的DPI,屏幕分辨率是什么?

我使用vs2010 - windowsform

可以任何人帮助我!!!



but that didn't work
how can I make my application has same DPI what ever screen resolution is??
I am using vs2010 - windowsform
can any one help me!!!

推荐答案


这篇关于c#dpi意识到应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 14:48