屏幕分辨率自适应算法
-
private void Resolution(Control.ControlCollection Con)
-
{
-
//遍历控件
-
System.Drawing.Rectangle rc = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
-
for (int i = 0; i < Con.Count; i++)
-
{
-
Con[i].Anchor= ((System.Windows.Forms.AnchorStyles)(System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left));
-
if (Con[i].Dock == DockStyle.Fill)
-
{
-
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)));
-
}
-
Con[i].Width = Con[i].Width * rc.Width / 1024;//现有屏幕比例和标准比例换算,标准为1024*768,
-
Con[i].Height = Con[i].Height * rc.Height / 738;//738为除去工具条后的标准Height.
-
Con[i].Left = Con[i].Left * rc.Width / 1024;
-
Con[i].Top = Con[i].Top * rc.Height / 738;
-
if (Con[i].Controls.Count > 0)
-
{
-
Resolution(Con[i].Controls);//递归
-
}
-
-
}
-
}
posted on 2008-10-20 17:20 布衣(Dream2008) 阅读(479) 评论(0) 收藏 举报
浙公网安备 33010602011771号