Adding A Statusbar

From WxWiki
Jump to: navigation, search

Adding a statusbar to the frame is even easier. Call the wxFrame method CreateStatusBar and the frame has a statusbar. As parameter, a number is passed that is used to create separate fields in the statusbar. With SetStatusText the text of a field can be changed.

SetStatusText(wxT("Ready"), 0);

This creates a statusbar with 3 fields. The first field will contain the text "Ready".

The statusbar can also be used to display a description of the selected menu. the code below shows how the code from Adding A Menubar is changed. When a menu is selected, the associated description is displayed in the first field of the statusbar.

// File menu
m_pFileMenu = new wxMenu();
m_pFileMenu->Append(wxID_OPEN, _T("&Open"), _T("Opens an existing file"));
m_pFileMenu->Append(wxID_SAVE, _T("&Save"), _T("Save the content"));
m_pFileMenu->Append(wxID_EXIT, _T("&Quit"), _T("Quit the application"));
m_pMenuBar->Append(m_pFileMenu, _T("&File"));

// About menu
m_pHelpMenu = new wxMenu();
m_pHelpMenu->Append(wxID_ABOUT, _T("&About"), _T("Shows information about the application"));
m_pMenuBar->Append(m_pHelpMenu, _T("&Info"));

next: Processing Menu Events