Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Multiple Toolbars in the PocketPC 2002

0.00/5 (No votes)
16 Mar 2003 1  
Handling multiple toolbars - Pocket Word-style.

Sample Image - CeMultiBar.jpg

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here