You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[HDPI] SystemAware - wrong Form.ClientSize with DPI other than 100% #12270
area-HDPIHDPI, not specific to Dpi mode of apparea-HDPI-PMv2Issues related to high DPI PerMonitorV2 modearea-HDPI-SAIssues related to high DPI SystemAware mode
Did it work in any of the earlier releases of .NET Core or .NET 5+?
Behavior is identical with .Net versions from 5.0 to 8.07.
.NET Framework 4.8. have similar issues but size error is smaller.
Issue description
SystemAware (or PerMonitorV2 starting scale) will calculate wrong Form.ClientSize for dpi more than 100%.
The problem was discovered in #12132 (comment).
See screenshots.
changed the title [-][HDPI] SystemAware - wrong Form.ClientSize with DPI other then 100%[/-][+][HDPI] SystemAware - wrong Form.ClientSize with DPI other than 100%[/+]on Oct 4, 2024
The AutoScaleDimensions property on a form is automatically generated by the designer during form serialization. It can also be changed manually, but essentially it's a value determined by the developer at design time. This is also the "baseline value" used by WinForms to calculate scaling.
On a 175% screen, CurrentAutoScaleDimensions = (12, 30).
This value is the logical size measured by Windows/GDI based on the current system font, WinForms simply reads it.
Therefore, at 175% scaling:
Horizontal font magnification ratio ≈ 12 / 7 = 1.714285…
Vertical font magnification ratio = 30 / 15 = 2.0
area-HDPIHDPI, not specific to Dpi mode of apparea-HDPI-PMv2Issues related to high DPI PerMonitorV2 modearea-HDPI-SAIssues related to high DPI SystemAware mode
Activity
[-][HDPI] SystemAware - wrong Form.ClientSize with DPI other then 100%[/-][+][HDPI] SystemAware - wrong Form.ClientSize with DPI other than 100%[/+]LeafShi1 commentedon Feb 6, 2026
The actual window size calculation method in WinForms at high DPI is not the same as the
Math.Round(DeviceDpi / (double)96, 2).When AutoScaleMode = Font, WinForms' actual algorithm is:
savedAutoScaleDimensions is (7, 15).
On a 175% screen,
CurrentAutoScaleDimensions = (12, 30).Therefore, at 175% scaling:
Horizontal font magnification ratio ≈ 12 / 7 = 1.714285…
Vertical font magnification ratio = 30 / 15 = 2.0
The calculated dimensions are: Width: 560 * 1.714285 = 960, Height: 250 * 2 = 500
kirsan31 commentedon Feb 6, 2026
@LeafShi1 thank you. We all went to wrong direction after here 😞