How can I change the MsgBox size?

24 vues (au cours des 30 derniers jours)
Muhendisleksi
Muhendisleksi le 3 Fév 2018
Commenté : Image Analyst le 18 Mai 2022
msgbox({'Dengeleme Sonuçları','Kaydedilmiştir!'}, 'Sonuçlar Kaydedildi!', 'warn')

Réponses (2)

Image Analyst
Image Analyst le 18 Mai 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 le 4 Fév 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 commentaires
Jan
Jan le 18 Mai 2022
I'm using my own implementation of message boxes. See an example here:
Image Analyst
Image Analyst le 18 Mai 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.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by