How can I change the MsgBox size?

37 views (last 30 days)
Muhendisleksi
Muhendisleksi on 3 Feb 2018
Commented: Image Analyst on 18 May 2022
msgbox({'Dengeleme Sonuçları','Kaydedilmiştir!'}, 'Sonuçlar Kaydedildi!', 'warn')

Answers (2)

Image Analyst
Image Analyst on 18 May 2022
@Eric Crump like I said in your other question, feel free to modify this:
function msgboxw(varargin)
try
% celldisp(varargin)
message = varargin{1};
if iscell(message)
message = char(message{:});
end
% Assign a title to the diaplog box if they entered one.
dialogTitleString = 'MATLAB Message';
% nargin
if nargin >= 2
dialogTitleString = varargin{2};
end
% If there is a backslash in the string (like from a folder), then it needs to be replaced by double backslashes.
message = strrep(message, '\', '\\');
% Replace underlines with \_ so the next character won't be a subscript.
message = strrep(message, '_', '\_');
CreateStruct.Interpreter = 'tex';
CreateStruct.WindowStyle = 'modal';
fontSize = 16;
% Embed the required tex code in before the string.
latexMessage = sprintf('\\fontsize{%d}%s', fontSize, message);
uiwait(msgbox(latexMessage, dialogTitleString, CreateStruct));
catch ME
errorMessage = sprintf('Error in msgboxw():\n%s', ME.message);
fprintf('%s\n', errorMessage);
uiwait(warndlg(errorMessage));
end
return; % from msgboxw()

Jan
Jan on 4 Feb 2018
You can't. The msgbox is drawn tight around the text. Either use a larger text, or write your own message box. See:
edit msgbox
  3 Comments
Jan
Jan on 18 May 2022
I'm using my own implementation of message boxes. See an example here:
Image Analyst
Image Analyst on 18 May 2022
@Eric Crump If you look at the documentation of msgbox, passing in a structure for one of the arguments is how they say to do it. How much more clear do you need than what the Mathworks itself says in their documentation. I even give you an example of how to change the font size.
I have a folder called Utilities on my path and in there there are a bunch of functions like msgboxw(). You can do the same thing. I know the default text is too tiny and msgbox is not modal so I just made my own and put it in the Utilities folder and forget about it. Just just call msgboxw() instead of msgbox() and that's it. So simple and I get it looking and behaving the way I want.

Sign in to comment.

Categories

Find more on Debugging and Analysis in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!