MATLAB Answers

How can I set a minimum window size for an app developed in app designer?

조회 수: 5(최근 30일)
Erika Yoshikawa
Erika Yoshikawa 2021년 7월 26일
댓글: Erika Yoshikawa 2021년 7월 27일
I am currently working on a app in app designer and I've been using the SizeChangedFcn call back to code for resizing the components. I want to set a minimum window size so it cannot be resized smaller than a certain size. I've been trying methods such as the one mentioned here (https://www.mathworks.com/matlabcentral/answers/361224-set-uifigure-size-limits-on-display-with-scaling-win10-r2017b) but it's not working, If someone knows how to do this, please can you help me?

채택된 답변

Adam Danz
Adam Danz 2021년 7월 26일
편집: Adam Danz 2021년 7월 26일
  1. Set the minimum size as an app property named minSize defined by 1x2 vector describing the minimum [width, height] (see how to define an app property). Example: minSize = [400, 300];
  2. Set the SizeChangedFcn to the two lines below. The second line assures that the App stays on your the screen.
Don't forget that AutoResizeChildren needs to be set to off to use SizeChangedFcn.
function UIFigureSizeChanged(app, event)
app.UIFigure.Position(3:4) = max(app.UIFigure.Position(3:4), minSize);
movegui(app.UIFigure)
end
  댓글 수: 3
Erika Yoshikawa
Erika Yoshikawa 2021년 7월 27일
No problem, thank you for your help!

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

추가 답변(0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by