Overload get(0, 'MonitorPositions')
Mostra commenti meno recenti
I am using someone else's toolbox that calls get(0, 'MonitorPositions') all over the place. The problem is that on my system get(0, 'MonitorPositions') returns nonsense. I understand that dual monitors are not officially supported by MATLAB despite the existence of a property like MonitorPositions.
Is it possible to overload either get(0, 'MonitorPositions') or whatever is called by get(0, 'MonitorPositions')?
The problem is not getting the monitor positions from the OS. I can write a MATLAB function that uses either java or system calls to get the monitor positions. I do not want to edit the code in the toolbox.
Risposta accettata
Più risposte (4)
Andrew Newell
il 24 Mar 2011
Judging by the documentation for Root properties, MATLAB does officially support dual monitors, but this is a documented bug. You could try doing this:
set(0,'MonitorPositions',get(0,'ScreenSize'))
but there's no guarantee you'll get good results.
2 Commenti
Daniel Shub
il 24 Mar 2011
Andrew Newell
il 24 Mar 2011
I wonder how you can tell in advance what is "official"?
Matt Fig
il 24 Mar 2011
What does the code you are using do with the value returned by
get(0,'MontorPosition')
Depending on your answer to that question, you could just hardcode some the pixel width and height of one of your monitors in the code. For example, everywhere you see this code, replace it with:
[1 1 1920 1200]
Or with whatever monitor size you have.
4 Commenti
Daniel Shub
il 24 Mar 2011
Matt Fig
il 24 Mar 2011
Of course it is easy with Ctrl+f do replace all in about 1 second. My suggestion is more of a do-or-die idea. I do not think you can overload the root. Generally, messing with the root is a no-no.
Matt Fig
il 24 Mar 2011
The other, non code-replacing option would be to simply unplug one of your monitors when using this toolbox.
Daniel Shub
il 24 Mar 2011
Andrew Newell
il 24 Mar 2011
1 voto
If the code is positioning windows, maybe you can follow the advice of How can I force MATLAB to bring up figure windows on the primary monitor or in a specific position on my dual monitor machine?.
2 Commenti
Daniel Shub
il 24 Mar 2011
Andrew Newell
il 24 Mar 2011
One solution, then, is to not set the position and size of the figures. Just let the figures open wherever Matlab decides to open them.
Andrew Newell
il 24 Mar 2011
1 voto
Categorie
Scopri di più su Startup and Shutdown in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!