How can I change the MsgBox size?

조회 수: 30 (최근 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 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