Page 1 of 1

Move a form to a different monitor

Posted: Tue Jan 08, 2019 10:09 am
by allistar
Hi all,
Has anyone implemented code that will move a Jade form to a different monitor? This is for a customer facing screen in a point of sale situation.

Thanks,
Allistar.

Re: Move a form to a different monitor

Posted: Thu Jan 10, 2019 9:54 am
by JohnP
Can't you just set the Form::left attribute? If your resolution is 1280 x 768 and left = 0 on the main monitor, on the left monitor you would set left to -1280. If your secondary monitor is on the right, you would set left to 1280.

Re: Move a form to a different monitor

Posted: Thu Jan 10, 2019 4:34 pm
by allistar
Hi John,
Yes, that's what we ended up doing. It only works if the monitors are laid out simply (e.g. to the left of, above etc). I was hoping for a call to something like "enumMonitors" which we would then display in a combo, and then "setWindowMonitor" to force a window to a specified monitor.

Thanks for the response,
Allistar.

Re: Move a form to a different monitor

Posted: Fri Jan 11, 2019 3:17 am
by ghosttie
There are some Windows APIs to do stuff like that

Re: Move a form to a different monitor

Posted: Fri Jan 11, 2019 7:33 am
by BeeJay
If you don't want to work out calls to that API, you could potentially use Window::getMonitorArea for the form, and then call a recursive routine that looks at the 9 areas around that monitor by adding/subtracting the height/width of that monitor from the current top/left of the form, and then call Window::getMonitorArea. If it has the same values as a prior monitor, there's no monitor on that 'side' of the current monitor or you have previously processed that monitor. If it has different values to any prior monitor, it's a new monitor and you can then recurse back into the method with that new monitor as the 'starting point'. It's a bit of a kludge, but it should find 'all' the uniquely positioned monitors in short order and you can then give the users a combo of the 'available' monitors in that system.

Here's the results of this type of routine on my laptop with two monitors connected:

Code: Select all

Next monitor: left: -1920 top: 0 width: 1920 height: 1200 Next monitor: left: 0 top: 0 width: 1920 height: 1200
And here's what it looks like with all three monitors active:

Code: Select all

Next monitor: left: -1920 top: 15 width: 1920 height: 1200 Next monitor: left: -988 top: 1215 width: 1920 height: 1080 Next monitor: left: 0 top: 0 width: 1920 height: 1200
Cheers,
BeeJay.