Borrar filtros
Borrar filtros

GUI figure doesn't move

10 visualizaciones (últimos 30 días)
Andrea Le
Andrea Le el 5 de Mzo. de 2017
Comentada: Andrea Le el 7 de Mzo. de 2017
Hi all,
I tried to move my GUI so part of it is in monitor 1 and the other part in monitor 2. I tried either use movegui or using groot to get all monitor position and set the figure handle to the set position but the GUI . My first monitor has [3200x1800] pixels and the second monitor is [1024x768]. Any suggestion please?
r = groot;
pos = r.MonitorPositions;
posShift = [pos(2,1)-500,pos(2,2)];
set(handles.figure1,'position',pos(1,1:2)+posShift ,pos(1.3:4)]);
  2 comentarios
Sam McDonald
Sam McDonald el 7 de Mzo. de 2017
The last line of code seems to have a few typos. I assume this is what you wanted:
set(handles.figure1,'Position',[pos(1,1:2)+posShift, pos(1,3:4)]);
Jan
Jan el 7 de Mzo. de 2017
The shown code should move the GUI. The only possible problem could be, that it does not move it to the desired position. Therefore Sam's idea could be the point: Perhaps the figure is not moved, because the line contains typos and Matlab stops with an error?

Iniciar sesión para comentar.

Respuesta aceptada

Jan
Jan el 7 de Mzo. de 2017
There is a limitation with setting the size of a Matlab figure e.g. when the limits exceed the monitor size:
siz = get(groot, 'ScreenSize'); % e.g. [1 1 1920 1200]
FigH = figure('OuterPosition', siz);
drawnow;
get(FigH, 'OuterPosition');
Under Windows you can use https://www.mathworks.com/matlabcentral/fileexchange/31437-windowapi to set the window where ever you want, even in fullscreen (on top on the taskbar) or beyound several screens.
  1 comentario
Andrea Le
Andrea Le el 7 de Mzo. de 2017
Thanks Jan. This works great!

Iniciar sesión para comentar.

Más respuestas (1)

Sam McDonald
Sam McDonald el 7 de Mzo. de 2017
Editada: Sam McDonald el 7 de Mzo. de 2017
Assuming you are using GUIDE to build your GUI, this may simply be a limitation of GUIDE or using MATLAB on multiple monitors. Although there are settings available to access the screen sizes and position the GUI across multiple monitors, the resulting GUI position may not be what you asked for. This is especially the case when positioning GUIs that are larger than the resolution of one of your monitors. However, there are still a couple steps you could try:
1. Verify that you are working with pixel units by executing the following code:
set(handles.figure1, 'Units', 'Pixels');
2. Change to "Proportional" resize behavior (Tools -> GUI Options -> Resize Behavior, and change that to "Proportional").
3. Use App Designer, which has been introduced as a replacement to GUIDE since the R2016b release. It may have the functionality you are looking for.
Technically, MATLAB is not fully supported on ALL dual-monitor setups as it is not practical to qualify every possible setup.
  1 comentario
Andrea Le
Andrea Le el 7 de Mzo. de 2017
Thank you Sam. I didn't know about the App Designer. I'll check it out

Iniciar sesión para comentar.

Categorías

Más información sobre Migrate GUIDE Apps en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by