How can I change the font size of MsgBox?

조회 수: 164 (최근 30일)
Muhendisleksi
Muhendisleksi 2018년 4월 16일
댓글: Claudio Camarra 2020년 4월 8일
if f==0 || f <0
Message = sprintf('Serbestlik derecesi %d\n DENGELEME YOK!!! ',f);
h = msgbox(Message,...
'Dikkat', 'warn');
end

답변 (2개)

Adam Danz
Adam Danz 2018년 6월 26일
편집: Adam Danz 2018년 8월 20일
Here's a function I wrote that does exactly this. Pass the handle of the msgbox() and the fontsize to the function.
If you don't want a function, here's the basics:
First get the handle to the text within the message box, then change the font size. Here's a demo.
mh = msgbox('I can barely read this.', 'test'); %create msgbox
th = findall(mh, 'Type', 'Text'); %get handle to text within msgbox
th.FontSize = 14; %Change the font size
If you increase the font size too much, you'll need to expand the message box to fit the extent of the text.
deltaWidth = sum(th.Extent([1,3]))-mh.Position(3) + th.Extent(1);
deltaHeight = sum(th.Extent([2,4]))-mh.Position(4) + 10;
mh.Position([3,4]) = mh.Position([3,4]) + [deltaWidth, deltaHeight];
Lastly, allow the user to resize the window if needed:
mh.Resize = 'on';

Anibal Siguenza Torres
Anibal Siguenza Torres 2018년 8월 20일
편집: Anibal Siguenza Torres 2018년 8월 20일
The easiest is to use the TeX format so the subset of markup supported by matlab can be used. To activate them you have to create an structure and send it as parameter as follows:
CreateStruct.Interpreter = 'tex';
CreateStruct.WindowStyle = 'modal';
msgbox('\fontsize{18} Now is big =)', CreateStruct)

카테고리

Help CenterFile Exchange에서 Dialog Boxes에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by