GUI figure doesn't move

12 次查看(过去 30 天)
Andrea Le
Andrea Le 2017-3-5
评论: Andrea Le 2017-3-7
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 个评论
Sam McDonald
Sam McDonald 2017-3-7
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 2017-3-7
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?

请先登录,再进行评论。

采纳的回答

Jan
Jan 2017-3-7
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 个)

Sam McDonald
Sam McDonald 2017-3-7
编辑:Sam McDonald 2017-3-7
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 个评论
Andrea Le
Andrea Le 2017-3-7
Thank you Sam. I didn't know about the App Designer. I'll check it out

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Migrate GUIDE Apps 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by