Sign in with Microsoft
New to Microsoft? Create an account.

狀況

實作自己的縮放比例高 DPI 設定的邏輯的 Windows Form 應用程式可能會遇到不尋常的縮放比例,如果這些應用程式使用下列的.config 檔設定,選擇 4.5.2 高 DPI 時,Microsoft.NET Framework 變更成︰

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

</appSettings>


解決方案

套用的縮放比例,縮放值之上的應用程式將會遇到額外時它們.NET Framework 4.5.2 的高 DPI 改良選擇縮放比例。若要解決這個問題,更新應用程式的縮放比例的邏輯,以套用縮放比例, ToolStrip.ImageScalingSize的預設值。這項變更會避免留下的多餘縮放比例。

例如,下列程式碼的應用程式會兩次縮放工具帶按鈕︰

public MyToolStrip()
{

IntPtr hDC = GetDC(new HandleRef(null, IntPtr.Zero));

double xFactor = GetDeviceCaps(new HandleRef(null, hDC), LOGPIXELSX) / 96.0;

double yFactor = GetDeviceCaps(new HandleRef(null, hDC), LOGPIXELSY) / 96.0;

this.ImageScalingSize = new Size((int)(this.ImageScalingSize.Width * xFactor), (int)(this.ImageScalingSize.Height * yFactor));

InitializeComponent();

}


您可以使用下列程式碼來調整從常數的預設大小,或您所需的影像的大小︰

this.ImageScalingSize = new Size((int)(16 * xFactor), (int)(16 * yFactor));


  

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?

Thank you for your feedback!

×