When the app closes, it reads the top-left corner of every open window (WIndow.Top and WIndow.Left) and saves them to disk. When the app opens again, it reads the X-Y coordinates from disk, and positions the windows to where they were when the app closed. This works fine.
Now add a second monitor. If both monitors have the same scale, no problem. But when one monitor has a different scale than the other, crap happens.
Monitor(0) has 250% scale
Monitor(1) has 150% scale
It is not practical to have the monitors the same scale, because while they are both identical 4K resolutions, one is many times the other in physical size.
When I set the Y position of a window on monitor 1 at 864 (Window.Top = 864), it works. The window is completely on the screen and visible, and it still has a lot of extra room below the window to the bottom of the screen.
When I set the Y position of the same window on monitor 1 at 865 (Window.Top =865), the window disappears. It exists, but it is completely below Screen 1. No part of the window is visible. When I read back the Y position from the window (Y = Window.Top), it reads 1442, even though I just wrote 865.
I have breakpointed and debugged the app. I am certain there is no problem with the code. I set a breakpoint to watch the 864 value go into Window.Top, and then immediately read 1442 from Window.Top in the debugger. The stored and retrieved Y values are different. Every value over 864 has the same result, that is, XOJO positions the window 1.66 times lower than the actual setting.
In other words, the value XOJO writes to the window is 1.66 times the actual value the code writes to the Window function, but only if the .Top value is over 864.
What is going on? Surely there has to be a way to work with screens that are not of the same scale.