Move a form to a different monitor

For questions and postings not covered by the other forums
allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

Move a form to a different monitor

Postby allistar » Tue Jan 08, 2019 10:09 am

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.

JohnP
Posts: 73
Joined: Mon Sep 28, 2009 8:41 am
Location: Christchurch

Re: Move a form to a different monitor

Postby JohnP » Thu Jan 10, 2019 9:54 am

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.

allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

Re: Move a form to a different monitor

Postby allistar » Thu Jan 10, 2019 4:34 pm

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.

User avatar
ghosttie
Posts: 181
Joined: Sat Aug 15, 2009 1:25 am
Location: Atlanta, GA, USA
Contact:

Re: Move a form to a different monitor

Postby ghosttie » Fri Jan 11, 2019 3:17 am

There are some Windows APIs to do stuff like that
I have a catapult. Give me all the money or I will fling an enormous rock at your head.

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: Move a form to a different monitor

Postby BeeJay » Fri Jan 11, 2019 7:33 am

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.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 9 guests