msgbox does not show title

4 Ansichten (letzte 30 Tage)
Kingsbury Browne
Kingsbury Browne am 6 Jun. 2018
Kommentiert: OCDER am 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.
  1 Kommentar
Walter Roberson
Walter Roberson am 6 Jun. 2018
It works for me on R2018a on Mac

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

OCDER
OCDER am 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 Kommentare
Walter Roberson
Walter Roberson am 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 am 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by