我想获得显示器的真实大小,也就是说我无论怎么改分辨率,获得的显示器屏幕大小应该都是一样的。有办法解决吗

解决方案 »

  1.   

    Rectangle rect=System.Windows.Forms.SystemInformation.VirtualScreen;
    int width=rect.Width;
    int height=rect.Height;
      

  2.   

     获取屏幕的像素大小:
           float _pxwidth;
            public void CalcPixWidth()
            {
                PictureBox p = new PictureBox();
                Graphics g = Graphics.FromHwnd(p.Handle);
                IntPtr hdc = g.GetHdc();
                int width = GetDeviceCaps(hdc, 4);
                int pix = GetDeviceCaps(hdc, 8);
                _pxwidth = pix / width;
            }
    然后再去乘屏幕的水平与垂直分辨率
      

  3.   

    Form form1=new From(Screen.PrimaryScreen.WorkingArea.Width,Screen.PrimaryScreen.WorkingArea.Height);
      

  4.   

    GetDeviceCaps(hdc, 4)是什么函数?
      

  5.   

    [DllImport("gdi32.dll")]
            public static extern int GetDeviceCaps(IntPtr hdc, int Index);