Description
Hello,
In a WPF project, I need to position different windows on multiple screens using dpi awarness in PerMonitorV2 mode.
After several tests with Framework 4.8 or Core 3.1, I noticed a problem with the positioning values of the windows.
So, I wrote a little test program to retrieve some messages sent to my window using a WndProc function to check where the problem was.
For the test, I move my window between 2 monitors with different scales.
If I move around the monitor at 100% scale, in the image below, you can see that my window position values correctly match the position values given by the WM_WINDOWPOSCHANGING message.
When deciding to switch my window to the monitor at 150% scale, I receive the scale change message (WM_DPICHANGED).
In the image below, you can see the suggested position and size for the window.
The scale goes to 150%
The size values are multiplied by 1.5.
Height: 500x1.5 = 750
Width: 800x1.5 = 1200
Position values remain constant
The WM_WINDOWPOSCHANGING message confirms the acceptance of this suggested size and position.
After this change of scale, I see that the values for the size of my window have been divided by 1.5 compared to the suggestion in order to keep these values constant.
Me.height: 750 / 1.5 = 500
Me.width: 1200 / 1.5 = 800
On the other hand, the position values of my window were also divided by 1.5.
Me.top: 91 / 1.5 = 61
Me.left: 1212 / 1.5 = 808
If I continue to move my window on the monitor whose scale is 150%, you can see that the WM_WINDOWPOSCHANGING message confirms the position in logical units while the position values of my window are still divided by the scale of the monitor.
My window positioning values are logical units (96dpi). They should not be divided by the monitor scale.
Is the problem related to Framework 4.8 or Core 3.1?
You can perform the test using the program contained in the zip file.