How to prevent resizing larger than a certain amount
4 views (last 30 days)
Show older comments
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
0 Comments
Answers (1)
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!