필터 지우기
필터 지우기

GUI figure doesn't move

조회 수: 11 (최근 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
Andrea Le
Andrea Le 2017년 3월 7일
Thanks Jan. This works great!

댓글을 달려면 로그인하십시오.

추가 답변 (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