1. private void Resolution(Control.ControlCollection Con)
  2. {
  3. //遍历控件
  4. System.Drawing.Rectangle rc = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
  5. for (int i = 0; i < Con.Count; i++)
  6. {
  7. Con[i].Anchor= ((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left));
  8. if (Con[i].Dock == DockStyle.Fill)
  9. {
  10. Con[i].Font = new System.Drawing.Font("Microsoft Sans Serif", Con[i].Font.Size * rc.Width / 1024 ,Con[i].Font.Style, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  11. }
  12. Con[i].Width = Con[i].Width * rc.Width / 1024;//现有屏幕比例和标准比例换算,标准为1024*768,
  13. Con[i].Height = Con[i].Height * rc.Height / 738;//738为除去工具条后的标准Height.
  14. Con[i].Left = Con[i].Left * rc.Width / 1024;
  15. Con[i].Top = Con[i].Top * rc.Height / 738;
  16. if (Con[i].Controls.Count > 0)
  17. {
  18. Resolution(Con[i].Controls);//递归
  19. }
  20.  
  21. }
  22. }

相关文章:

  • 2021-08-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2022-12-23
猜你喜欢
  • 2022-02-08
  • 2022-12-23
  • 2021-08-07
  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
相关资源
相似解决方案