GUI figure doesn't move

7 vues (au cours des 30 derniers jours)
Andrea Le
Andrea Le le 5 Mar 2017
Commenté : Andrea Le le 7 Mar 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 commentaires
Sam McDonald
Sam McDonald le 7 Mar 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 le 7 Mar 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?

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 7 Mar 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 commentaire
Andrea Le
Andrea Le le 7 Mar 2017
Thanks Jan. This works great!

Connectez-vous pour commenter.

Plus de réponses (1)

Sam McDonald
Sam McDonald le 7 Mar 2017
Modifié(e) : Sam McDonald le 7 Mar 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 commentaire
Andrea Le
Andrea Le le 7 Mar 2017
Thank you Sam. I didn't know about the App Designer. I'll check it out

Connectez-vous pour commenter.

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by