msgbox does not show title

4 views (last 30 days)
Kingsbury Browne
Kingsbury Browne on 6 Jun 2018
Commented: OCDER on 6 Jun 2018
When trying to create a message box with a custom title, it does not show up for me.
CreateStruct.Interpreter = 'tex';
CreateStruct.WindowStyle = 'modal';
str_angle = sprintf('%.3f', angle);
str_true_vector_mag = sprintf('%.3f', true_vector_mag);
f = msgbox( {['Angle: ' str_angle '\circ'];['Distance: ' str_true_vector_mag ' m']} , 'Results' , CreateStruct);
I want the title to be 'Results', but for some reason the output does not show the title.
Thank you.

Accepted Answer

OCDER
OCDER on 6 Jun 2018
Your "Results" text isn't showing because the window is too small. Try making it wider as such:
angle = 30;
true_vector_mag = 15;
CreateStruct.Interpreter = 'tex';
CreateStruct.WindowStyle = 'modal';
str_angle = sprintf('%.3f', angle);
str_true_vector_mag = sprintf('%.3f', true_vector_mag);
f = msgbox({['Angle: ' str_angle '\circ'];['Distance: ' str_true_vector_mag ' m']} , 'Results' , CreateStruct);
f.Position(3) = 200; %<== MAKE FIGURE WIDER
  2 Comments
Walter Roberson
Walter Roberson on 6 Jun 2018
Note that the figure titles are handed off to the operating system being used, so the display will vary. On Mac El Capitan, 'Results' does show up, but Windows or Linux might display differently.
OCDER
OCDER on 6 Jun 2018
That's a good point - @Kingsbury, the solution I gave may not be robust for other OS with different display settings. Make sure to test it before deploying any software to others.
In Windows, small message boxes do have the title hidden behind the [Minimize, Expand, Close] symbols, which by default are spaced out a lot... A workaround would be to show the text "Results:" along the message inside the msgbox.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!