File Exchange Pick of the Week

Our best user submissions

Changing font size of built-in dialog boxes 5

Posted by Jiro Doke,

Jiro‘s Pick this week is msgboxFontSize by Adam Danz.

This utility reminded me of a very recent project, which would have benefited greatly. I was building an app that made use of warndlg and errordlg. I needed to show the app as part of a presentation, and that required me to make the fonts bigger. The app itself, I had control over. But there were no parameters I could tweak in warndlg and errordlg to make their fonts bigger. I ended up modifying the built-in functions themselves to allow me to specify the font size.

Adam’s utility would have saved me a lot of trouble. His function takes an existing dialog box created by msgbox, warndlg, errordlg and changes the font size and other properties by searching for the text objects.

For example, take this standard warning dialog.

h = warndlg('This is the normal error dialog','Error');

Let’s change the font size to 30, and while we’re at it, we’ll also change the text.

msgboxFontSize(h,30,'String','Notice how the font is bigger now!');

Notice that the dialog width is adjusted based on the font size.

I have a couple of enhancement requests for Adam.

  • It would be great if we could also change the font size of the buttons (“OK” button in the above example).
  • It would be even greater if the icon size (the exclamation mark icon in the above example) increased proportionally as well.


Give it a try and let us know what you think here or leave a comment for Adam.

Get the MATLAB code

Published with MATLAB® R2019a


Comments are closed.

5 CommentsOldest to Newest

Adam Danz replied on : 1 of 5
I just uploaded vs 2.2 which now applies changes to the buttons unless the name-value parameter "ignorebuttons" is true. However, the button size does not change (for now) so very large fonts may result in the text being larger than the button. The help section of the file shows how to access the icon and change its size. Maybe later I can add that feature, too. Also see the function supersizeme() that scales the font sizes of text within an axis or figure.
Dongdong Geng replied on : 2 of 5
There is an error here :
 h = msgbox('Hello world (20 pt font)', 'Example');
 msgboxFontSize(h, 20)
Error using msgboxFontSize The value of 'h' is invalid. Undefined function 'isvalid' for input arguments of type 'double'. Error in msgboxFontSize (line 64) parse(p,varargin{:})
Adam Danz replied on : 4 of 5
I just updated the function so that it works with older releases (v2.3). I replaced isvalid() with ishghandle() and I replaced dot notation with get/set. The function has been tested in r2014a, r2016a, r2017b, and r2019a. That should fix the problem. Thank you for reporting it, Dongdong Geng!
Jiro Doke replied on : 5 of 5
Thanks for updating the entry right away, Adam! It's work for you to maintain code that would work with older releases, but the users will definitely appreciate it. Thanks again.