I've written an application on Windows 10 19042.964 which shows four transparent windows (i.e. with WS_EX_LAYERED set) in a square configuration. These windows move back and forth between two external displays with different DPI settings. The primary display is on the right, and has its scaling set to 175%. The screen on the left has its scale set to 200%. The program calls SetProcessDpiAwareness shortly after startup, passing DPI_AWARENESS_SYSTEM_AWARE.
I set the size of each window to be 100x100, and then set the window positions so that all windows are adjacent and arranged in a square. When the windows move to the monitor on the left, their positions and sizes seem to be modified by the OS, so that the windows are no longer arranged in a square. However, if I avoid using the the WS_EX_LAYERED flag, the relative positions of the windows remain correct.
In short, enabling the WS_EX_LAYERED flag seems to cause the OS to interpret the arguments to SetWindowPos differently than when the WS_EX_LAYERED bit is not set. Windows seems to apply some additional scaling in this case. Is this behaviour documented anywhere? What technique should be used to precisely position WS_EX_LAYERED windows across multiple monitors with different scaling in an app with system DPI awareness? Is it possible to force SetWindowPos to behave in the same way, regardless of whether or not WS_EX_LAYERED is set?