C#笔记(15)DPI屏幕适配

app.manifest

<application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">falsedpiAware>
    windowsSettings>
  application>

app.config

<appSettings>
    <add key="EnableWindowsFormsHighDpiAutoResizing" value="false" />
  appSettings>

对应窗口:

form.Font = new Font("宋体", System.Drawing.SystemFonts.DefaultFont.Size / (float)(Graphics.FromHwnd(IntPtr.Zero).DpiX / 96.0), FontStyle.Regular);

你可能感兴趣的:(c#)