I have a status bar with 2 fields (created from the constructor of a wxFrame with "CreateStatusBar(2)".
The second field is for displaying a simple text that never changes.
I am trying to set the width of this field to the minimal needed for the text I wand to show.
Here is an example of what I have in the code :
Code: Select all
// Status bar (2 fields) wxStatusBar* stb=CreateStatusBar(2); // String to display in the second field wxString sTxt=_T("Hello, World!"); // Needed width for this text int widths; wxClientDC dc(stb); dc.GetTextExtent(sTxt, &widths, &widths); widths=-1; // Make first field extensible stb->SetStatusWidths(2, widths); SetStatusText(sTxt, 1);
I have tested with both wx-3.0.3 and wx-3.1.1.
I've also tested this code with the minimal sample (juste replace the code between the "#if wxUSE_STATUSBAR" and "#endif" lines 175 to 179 of the "minimal.cpp" file) and get the same result.
Does someone know a best way to achieve this ?