Overload get(0, 'MonitorPositions')
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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.
2 comentarios
Respuesta aceptada
Daniel Shub
el 21 de Sept. de 2011
2 comentarios
Jan
el 21 de Sept. de 2011
I haven't seen this thread before.
You can overload the "get" command by creating a function with this name in the Matlab path:
function Out = get(varargin)
Then you can check if the first two inputs are {0, 'MonitorPositions'} and create an adjusted output. In all other cases you can forward the input to the built-in "get":
Out = builtin('get', varargin{:});
You have to catch missing output and multiple inputs, but it is possible with some effort.
However, if upgrading solves the known bug, this is a far better idea.
Más respuestas (4)
Andrew Newell
el 24 de Mzo. de 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 comentarios
Matt Fig
el 24 de Mzo. de 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 comentarios
Matt Fig
el 24 de Mzo. de 2011
The other, non code-replacing option would be to simply unplug one of your monitors when using this toolbox.
Andrew Newell
el 24 de Mzo. de 2011
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 comentarios
Andrew Newell
el 24 de Mzo. de 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.
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!