How can I change the MsgBox size?

40 ビュー (過去 30 日間)
Muhendisleksi
Muhendisleksi 2018 年 2 月 3 日
コメント済み: Image Analyst 2022 年 5 月 18 日
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 件のコメント
Jan
Jan 2022 年 5 月 18 日
I'm using my own implementation of message boxes. See an example here:
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 Center および File ExchangeDebugging and Analysis についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by