+void MyFrame::OnSetStatusFields(wxCommandEvent& WXUNUSED(event))
+{
+ wxStatusBar *sb = GetStatusBar();
+
+ long nFields = wxGetNumberFromUser
+ (
+ "Select the number of fields in the status bar",
+ "Fields:",
+ "wxWindows statusbar sample",
+ sb->GetFieldsCount(),
+ 1, 5,
+ this
+ );
+
+ // we don't check if the number changed at all on purpose: calling
+ // SetFieldsCount() with the same number of fields should be ok
+ if ( nFields != -1 )
+ {
+ // we set the widths only for 2 of them, otherwise let all the fields
+ // have equal width (the default behaviour)
+ const int *widths = NULL;
+ if ( nFields == 2 )
+ {
+ static const int widthsFor2Fields[2] = { 200, -1 };
+ widths = widthsFor2Fields;
+ }
+
+ sb->SetFieldsCount(nFields, widths);
+
+ wxLogStatus(this,
+ wxString::Format("Status bar now has %ld fields", nFields));
+ }
+ else
+ {
+ wxLogStatus(this, "Cancelled");
+ }
+}
+