现在上级要求做一个工具栏,工具栏的大小限制很严格。
在1024*768的模式下是200像素*30像素
在800*600的模式下是156像素*23像素
这个要如何判断他的当前像素?

解决方案 »

  1.   

    用Screen.PrimaryScreen.WorkingArea.Width和Screen.PrimaryScreen.WorkingArea.Width获取当前显示器的像素,然后根据这个调整工具栏的Width和Height
      

  2.   

    这个不太好,不能应付多显示器的情况。用这个:
    Screen.FromRectangle(this.Bounds).Bounds;
      

  3.   

    System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;   
    System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;  
      

  4.   

    Rectangle rc = new Rectangle();
      Console.WriteLine(System.Windows.Forms.Screen.GetBounds(rc).Width);
      Console.WriteLine(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width);