Introduction
This article presents a solution on how to implement multiple toolbars in a PocketPC 2002 application. The idea came from an exchange in the Embedded/Mobile message board where this functionality was sought, especially the Pocket Word-like management of the toolbar ( http://www.codeproject.com/script/comments/forums.asp?forumid=13695#xx435722xx).
Implementation
The demonstration project (illustrated above) has two toolbars that are hidden or shown through commands in the main command bar. Note: the demo project is meant to illustrate the working of the toolbars, so no functionality has been implemented on them.
Both toolbars are created in CMainFrame::OnCreate
without the WS_VISIBLE
style. When the user issues a command to show a toolbar, the window is shown and RecalcLayout
is used to reposition everything inside the frame.
void CMainFrame::OnToolbarFormat()
{
CToolBarCtrl& rToolBar = m_wndCommandBar.GetToolBarCtrl();
m_bFormat = !m_bFormat;
m_wndFormat.ShowWindow(m_bFormat ? SW_SHOW : SW_HIDE);
RecalcLayout();
rToolBar.CheckButton(ID_TOOLBAR2, m_bFormat);
}
Note that there are no ON_UPDATE_COMMAND_UI
handlers in the demo. Checking and unchecking of the main command bar buttons is done explicitly in this message handler.
A final note on CToolBar
: I found no proper way to have it draw the top border, so I derived the dummy class CCeToolBar
with the single purpose of drawing the top border. If there is a better way to achieve this, please post it here.