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!