LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make sure a panel is not offscreen ?

Hello all,
My app has an ini file where my panel sizes and positions are saved.

The problem is that this file is shared between different setups, some using
multiple monitors, so if you launch on a single monitor the windows are
completely off-screen and inaccessible.
Is there some checks I can do before my SetPanelPos/SetPanelSize to ensure
that it will indeed be onscreen ?

It's not as easy as using GetMonitorAttribute as in some cases it can end up
in a dead zone (small monitor next to big one).

And GetMonitorFromPoint gives you the nearest monitor instead of telling you
that you are outside.

Maybe put a control key to reset and center the window position ?
--
Guillaume Dargaud
http://www.gdargaud.net/


0 Kudos
Message 1 of 3
(3,282 Views)

I think you could use GetPanelAttribute(..) to get the top, left, width, and height of the panel, then maximize the panel, then get the top, left, width, and height again.  Then you can check to see if the non-maximized panel coordinates falls within the maximized panel coordinates, and if not move the panel after you unmaximize it.  I believe this should work, as when the panel is maximized it will be moved to a screen if it is offscreen.  You should be able to do all of this before DisplayPanel(...) so the user won't see it.

Message Edited by tstanley on 11-21-2008 11:28 AM
0 Kudos
Message 2 of 3
(3,211 Views)
Yup, that's a good idea...

Except that this brings a few Linux bugs out of the woodworks.
In all honesty, they may be X-windows bugs and not related to CVI at all.

Here's the setup: I run the application _remotely_ on a Linux machine, but
from a dual-monitor Windows machine. I use Xming as an X-windows client.

In this setup, the functions *Monitor*() don't work: they consider there's
only one monitor. Some of the consequences are:
- if you [center on load] a panel, it shows up between the two monitors.
- same thing for any kind of popup.
- if you maximize a panel it covers BOTH monitors.
- On Win coords 0,0 are the upper left of the main monitor, if the secondary
is on the left, its x will be <0. On X-windows, the monitor farther up and
left has coord 0,0.

I haven't tried on a dual-monitor Linux machine directly but soon will.

So your suggestion doesn't work on this rather complex setup (but I don't
blame you) !
C;-)
--
Guillaume Dargaud
http://www.gdargaud.net/
"10 March... 0 hours climbing. Write 5 pages to my mother in law. Getting
desperate." - Dave Johnson's journal entry while stormbound in Alaska.


0 Kudos
Message 3 of 3
(3,174 Views)