msgbox does not show title
4 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
OCDER
2018-6-6
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 个评论
Walter Roberson
2018-6-6
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
2018-6-6
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!