How can I change the font size of MsgBox?

169 Ansichten (letzte 30 Tage)
Muhendisleksi
Muhendisleksi am 16 Apr. 2018
Kommentiert: Claudio Camarra am 8 Apr. 2020
if f==0 || f <0
Message = sprintf('Serbestlik derecesi %d\n DENGELEME YOK!!! ',f);
h = msgbox(Message,...
'Dikkat', 'warn');
end

Antworten (2)

Adam Danz
Adam Danz am 26 Jun. 2018
Bearbeitet: Adam Danz am 20 Aug. 2018
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 am 20 Aug. 2018
Bearbeitet: Anibal Siguenza Torres am 20 Aug. 2018
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)

Kategorien

Mehr zu Dialog Boxes finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by