フィルターのクリア

How to prevent resizing larger than a certain amount

2 ビュー (過去 30 日間)
Chris Herrera
Chris Herrera 2015 年 7 月 29 日
コメント済み: Chris Herrera 2015 年 7 月 29 日
Hi All, I have a GUI I make programatically and the size it starts at is full screen (i.e. in the figure(property,value...'Position',get(0,'screensize'),...)
I want to know if there is a way to prevent users from resizing it larger but still be able to resize it smaller. Apart from the Figure size, everything is in normalized units. I have a dual monitor set up (laptop with external monitor) and the figure first shows at the full screen of my laptop window. I want to be able to resize it smaller but not any larger than it's starting size (laptop full screen size).
I tried setting the figure resize function as:
function resizeMainFigure(hObject,eventdata)
% -------
% Prevent oversizing the window
% -------
newPosition = get(mainFigure,'position');
if newPosition(3) > scrsz(3); newPosition(3) = scrsz(3); end
if newPosition(4) > scrsz(4); newPosition(4) = scrsz(4); end
set(mainFigure, 'Position', newPosition);
end
Where scrsz = get(0,'screensize'); (it spans multiple functions) and mainFigure is the variable storing the figure handle. I'm using 2015A

回答 (1 件)

Jan
Jan 2015 年 7 月 29 日
This does not work with HG2 yet, but I'll fix this today.
  2 件のコメント
Chris Herrera
Chris Herrera 2015 年 7 月 29 日
Thank you both for the link. It looks like exactly what I need. What is HG2 if you don't mind?
Chris Herrera
Chris Herrera 2015 年 7 月 29 日
Hi I got this error when using LimitSizeFig.
Warning: figure JavaFrame property will be obsoleted in a future release. For more information see the JavaFrame resource on the MathWorks web site. > In LimitSizeFig (line 97) No appropriate method, property, or field 'fFigureClient' for class 'com.mathworks.hg.peer.HG2FigurePeer'. Error in LimitSizeFig (line 101) jClient = jFrame.fFigureClient;
Code used to produce error:
scrsz = get(0,'ScreenSize');
figureSize = [scrsz(1)+5,scrsz(2)+5,scrsz(3)-10,scrsz(4)-10];
mainFigure = figure('Visible','off','Position',figureSize,'Name','CeleST: Video Processing - Choose the videos to process, define the swimming zones, launch the processing','numbertitle','off', 'menubar', 'none', 'resizefcn', @resizeMainFigure);
LimitSizeFig(mainFigure, 'max', [figureSize(3) figureSize(4)]);
I'm running 2015A

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by