Can movegui in openfig be disabled?

조회 수: 3 (최근 30일)
Johnny B
Johnny B 2014년 4월 23일
댓글: Johnny B 2014년 4월 24일
I have a dual-monitor setup with my left (primary) monitor rotated into a portrait orientation, so that the monitor width is only 1024 pixels. I'm trying to run a program that loads a GUI figure that is 1300 pixels wide. When I run the program, the figure gets resized to be only 1014 pixels wide. The culprit appears to be a call to movegui(fig(n),'onscreen') in openfig , which gets called to open the .FIG file. I don't want the figure to be resized; in my extended desktop, the figure would be just fine spilling into the other monitor. Plus, the figure's children's units are not normalized, so important controls are being chopped off the right side of the figure.
For now, I've commented-out the call to movegui on line 109 of openfig . I'm always reluctant to modify Mathworks-supplied files, so I was looking for an alternate method of keeping MATLAB from resizing the figure.

답변 (1개)

Walter Roberson
Walter Roberson 2014년 4월 24일
GUIDE is an approximation of a GUI creation tool. Sometimes you need to repair the code it generates, such as by commenting out movegui() in your case.
  댓글 수: 1
Johnny B
Johnny B 2014년 4월 24일
I guess I wasn't clear enough in my description of my problem. GUIDE has nothing to do with it; it's the act of opening the figure that causes the problem. I'm typing this on a computer with a single monitor with a width of 1680 pixels. Here's an example of what MATLAB will do to me:
>> get(0,'screenSize')
ans =
1 1 1680 1050
>> figure
>> plot(randn(100,1))
>> set(gcf,'position',[1 400 1680 420])
>> get(gcf,'position')
ans =
1 400 1680 420
{{{ Here I save the figure using the figure's menu }}}
>> close
{{{ Here I open the figure using the command window menu }}}
>> get(gcf,'position')
ans =
38 400 1664 414
Notice that the figure's width has been reduced to 16 pixels narrower than my screen. When you open a figure in MATLAB, it uses $matlabroot\toolbox\matlab\graphics\openfig.m to do the work. This function in turn calls $matlabroot\toolbox\matlab\uitools\movegui.m, which makes sure the figure it's opening fits on the screen. I suppose that the behavior in this example is reasonable, though I'd prefer that it not make the figure smaller than the actual screen width. The problem really occurs when the primary monitor is narrower than the second monitor. The act of opening the figure causes MATLAB to resize the figure to fit on the primary monitor, even if "extended desktop" would allow it to spill onto the second monitor. I think this is really a bug in movegui ; it should use MonitorPositions instead of ScreenSize to decide whether the figure will fit.

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

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by