C#做的一个程序界面,当分辨率为8000*600时,显示不完整,分辨率太大了时,又留出很多空白。有些文本当界面缩小时,也挤到一块去了。像这种情况应该是比较普遍的,应该怎么解决呢。我们用播放器看电影时,就可以自由缩放而不会影响到电视的画面,为什么程序就不可以。

解决方案 »

  1.   

    Screen.PrimaryScreen.Size //屏幕大小
      

  2.   


      //检查当前计算机的显示情况,便于调节窗体
            private void CheckUserScreenArea()
            {
                //检查屏幕分辨率
                if (Screen.GetWorkingArea(this).Width < 1024 | Screen.GetWorkingArea(this).Height < 768)
                {
                    //MessageBox.Show("您的显示器分辨率过低或者可用的桌面区域过小,本程序可能无法显示完全。\r\n推荐调整至1024x768或更高分辨率,或调节Windows开始菜单栏的宽度以增加可用桌面显示区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    this.MaximumSize = new Size(Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height);
                    this.MinimumSize = new Size(Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height);
                    this.Width = Screen.GetWorkingArea(this).Width;
                    this.Height = Screen.GetWorkingArea(this).Height;
                    this.Top = Screen.GetWorkingArea(this).Height / 2 - this.Height / 2;
                    this.Left = Screen.GetWorkingArea(this).Width / 2 - this.Width / 2;            }
                else
                {
                    this.MaximumSize = new Size(Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height);
                    this.MinimumSize = new Size(Program.MinFormWidth, Program.MinFormHeight);
                    this.Width = Screen.GetWorkingArea(this).Width;
                    this.Height = Screen.GetWorkingArea(this).Height;
                    this.Top = Screen.GetWorkingArea(this).Height / 2 - this.Height / 2;
                    this.Left = Screen.GetWorkingArea(this).Width / 2 - this.Width / 2;            }
                if ((Screen.GetWorkingArea(this).Width >= Program.NormalFormWidth) && (Screen.GetWorkingArea(this).Height >= Program.NormalFormHeight))
                {
                    this.MaximumSize = new Size(Program.MaxFormWidth, Program.MaxFormHeight);
                    this.MinimumSize = new Size(Program.MinFormWidth, Program.MinFormHeight);
                    this.Width = 1024;//Program.NormalFormWidth;
                    this.Height = 768;//Program.NormalFormHeight;
                    this.Top = Screen.GetWorkingArea(this).Height / 2 - this.Height / 2;
                    this.Left = Screen.GetWorkingArea(this).Width / 2 - this.Width / 2;
                }
            }
      

  3.   

    使用dock,设置Acchor属性
    判断分辨率   
    在不同分辨率下调整控件坐标
    窗体加载resize时改变坐标  
     
      

  4.   

    给楼主的建议:
    1、用滚动条,界面显得不友好;
    2、建议控件设置dock的属性;
    3、如果控件太多,最好归类放在容器中;
      

  5.   

    让我看下你的using指令和引用。 谢谢