Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

狀況

實作自己的縮放比例高 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?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×