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
When display setting is changed or display scale(dpi) is changed while the application is running, SystemParameters.WorkArea does not return proper value.
If you programatically change Top or Left property of Window that are relative to WorkArea.Width/WorkArea.Height, position of the Window would be absurd.
Width and Height are scaled without any problem. they will be just bigger and smaller to display ratio.
Reproduction Steps
Build app with PerMonitorV2 enabled.
Run app with 100% or 150% display scale ratio.
Change display scale ratio 100% to 150% or 150% to 100%.
Change Window's Top or Left property programatically that are relative to WorkArea's value. (i.e. right bottom corner or work area)
voilà!
Expected behavior
SystemParameters.WorkArea returns proper value.
Actual behavior
awkwardly scaled RECT is returned.
Regression?
I only tested on .net framework environment that supports PerMonitorV2.
Known Workarounds
Use same API that SystemParameters.WorkArea uses. SystemParametersInfo
SystemParameters(SPI_GETWORKAREA, 0, ref RECT, 0)
Get current display scale with VisualTreeHelper.GetDpi() or DpiChanged event.
adjust value of returned RECT from SystemParameters() with DpiScale instance.
RECT.Left/RECT.Right will be divided with DpiScale.DpiScaleX and RECT.Top/RECT.Bottom will be divided with DpiScale.DpiScaleY
divided values are correct WorkArea information.
Impact
No response
Configuration
.NET framework (4.7.2, 4.8.1)
Windows 10/11 (x64)
AnyCPU builds
Other information
No response
The text was updated successfully, but these errors were encountered:
What does the current API do differently from the workaround that makes it wrong? ("absurd" and "awkward" are not very helpful, does it give values using the old DPI for example?)
If I retrieve current workArea through SystemParameters with 1920x1080(FHD), 100% scaling taskbar attached side of screen(left or right), I would get 1080 as bottom coordinate of workArea. Then, I change display scaling 100% to 125% or 150%. It still gives me 1080 as bottom coordinate(height) but right coordinate(width) is changed.
The SystemParameters.WorkArea.Bottom should be 864 (125%) and 720 (150%).
Description
When display setting is changed or display scale(dpi) is changed while the application is running,
SystemParameters.WorkArea
does not return proper value.If you programatically change Top or Left property of Window that are relative to
WorkArea.Width
/WorkArea.Height
, position of the Window would be absurd.Width and Height are scaled without any problem. they will be just bigger and smaller to display ratio.
Reproduction Steps
Expected behavior
SystemParameters.WorkArea returns proper value.
Actual behavior
awkwardly scaled RECT is returned.
Regression?
I only tested on .net framework environment that supports PerMonitorV2.
Known Workarounds
SystemParametersInfo
SystemParameters(SPI_GETWORKAREA, 0, ref RECT, 0)
VisualTreeHelper.GetDpi()
orDpiChanged
event.RECT
fromSystemParameters()
withDpiScale
instance.RECT.Left
/RECT.Right
will be divided withDpiScale.DpiScaleX
andRECT.Top
/RECT.Bottom
will be divided withDpiScale.DpiScaleY
Impact
No response
Configuration
Other information
No response
The text was updated successfully, but these errors were encountered: