0
我正在使用下面的例程 根據屏幕分辨率在運行時調整控件和文本的大小。 除了字體如「Wingdings 3」,這工作正常。 「Wingdings 3」將帶上實際的字符「Å」而不是「左箭頭」。 任何想法爲什麼?調整特殊字體的大小
public void ResizeControls(Control objCtl)
{
foreach (Control cChildren in objCtl.Controls)
{
if (cChildren.HasChildren)
{
ResizeControls(cChildren);
}
else
{
cChildren.Size = new Size(Screen.PrimaryScreen.Bounds.Width * cChildren.Width/DesignWidth, Screen.PrimaryScreen.Bounds.Height * cChildren.Height/DesignHeight);
cChildren.Location = new Point(Screen.PrimaryScreen.Bounds.Width * cChildren.Left/DesignWidth, Screen.PrimaryScreen.Bounds.Height * cChildren.Top/DesignHeight);
if ((cChildren.GetType() == typeof(System.Windows.Forms.Label) | (cChildren.GetType() == typeof(System.Windows.Forms.Button))))
cChildren.Font = new Font(cChildren.Font.FontFamily.Name, Screen.PrimaryScreen.Bounds.Height * cChildren.Font.Size/DesignHeight, cChildren.Font.Style, cChildren.Font.Unit, ((byte)(0))); // <-- HERE RESIZING A CONTROLS FONT PROPERTY
}
}
objCtl.Size = new Size(Screen.PrimaryScreen.Bounds.Width * objCtl.Width/DesignWidth, Screen.PrimaryScreen.Bounds.Height * objCtl.Height/DesignHeight);
objCtl.Location = new Point(Screen.PrimaryScreen.Bounds.Width * objCtl.Left/DesignWidth, Screen.PrimaryScreen.Bounds.Height * objCtl.Top/DesignHeight);
if ((objCtl.GetType() == typeof(System.Windows.Forms.Label)) | (objCtl.GetType() == typeof(System.Windows.Forms.Button)))
objCtl.Font = new Font(objCtl.Font.FontFamily, Screen.PrimaryScreen.Bounds.Height * objCtl.Font.Size/DesignHeight, objCtl.Font.Style, objCtl.Font.Unit, ((byte)(0))); // <-- HERE RESIZING A CONTROLS FONT PROPERTY
}