2014-09-03 100 views
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 
    } 

回答

1

明白了。我将GDI字符集设置为0,而不是复制字体原始GDI字符集。

"objCtl.Font.GdiCharSet"