How can I change the MsgBox size?

26 次查看(过去 30 天)
msgbox({'Dengeleme Sonuçları','Kaydedilmiştir!'}, 'Sonuçlar Kaydedildi!', 'warn')

回答(2 个)

Image Analyst
Image Analyst 2022-5-18
@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 2018-2-4
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 个评论
Image Analyst
Image Analyst 2022-5-18
@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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Debugging and Analysis 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by