Click here to Skip to main content
13,548,424 members
Click here to Skip to main content
Add your own
alternative version


27 bookmarked
Posted 12 Mar 2003
Licenced CPOL

A Selection Bar for the PocketPC 2002

, 12 Mar 2003
Rate this:
Please Sign up or sign in to vote.
An implementation of the selection bars found on PocketPC 2002 applications.

Sample Image - CeSelectBar.jpg


This article describes one implementation of the selection bar which is present in Microsoft's applications for the PocketPC 2002. After looking very thoroughly through the PPC 2002 SDK, I found no API that would implement this functionality, so I decided to implement it myself.


The selection bar is implemented through the CCeSelectBar class, derived from MFC's own CControlBar. In this first approach to the selection bar implementation, I chose to allow only for menus to be displayed when the user clicks one of the two available selections. These are either on the top left or on the top right. Each selection is defined in terms of a menu (CMenu*), one title string, one option string and an optional icon.

Each menu is identified by the integers 0 for the left, and 1 for the right. These should be used in all methods that have an nPos parameter. This is not a very sophisticated approach, but you can be sure that the debug version will assert, should you fail on this.

The title string is displayed when the menu is active (see the right selection on the picture) and does not typically change during the execution of the program. The option string is displayed when the menu is not active, and is meant to inform the user of what option is currently selected. The icon should be 16 x 16 pixels and can be changed anytime, possibly as a response to a user's selection.

This bar can only live attached to the top and has a fixed height.

Using the Selection Bar

Being a CControlBar-derived class, you should create it in your CMainFrame::OnCreate() method, like in the demo project. This project uses CChildView::SetSelectBar() in order to have the child view know the selection bar. In fact, it is the child view the one that is responsible for instancing both left and right menus and to process their states, and the setup of both menus is done in this method.

The menu command handlers, besides displaying the selected option in a message box, also set up the option string and the menu state through CheckMenuRadioItem().

Clearing a Menu

If during the course of your application you need to clear one of the menus, use the CCeSelectBar::ClearMenu() method.

Replacing a Menu

Any one of the two menus can be replaced at any time using the initialization process as shown in the demo project. Please notice that managing the CMenu objects is your responsibility, not the bar's.

Look and Feel

I tried very hard to make this bar both look and operate like the ones Microsoft has implemented in its applications. The problem is that even they seem to be doing this differently in each application. Just look at how they do it in File Explorer and in the Inbox. I chose to copy the first one's look and feel.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

João Paulo Figueira
Software Developer (Senior) Frotcom International
Portugal Portugal
I work on R&D for Frotcom International, a company that develops web-based fleet management solutions.

You may also be interested in...

Comments and Discussions

QuestionHow to add control in smart device app in c# Pin
MagdyYousif7-Apr-04 4:39
memberMagdyYousif7-Apr-04 4:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04-2016 | 2.8.180515.1 | Last Updated 13 Mar 2003
Article Copyright 2003 by João Paulo Figueira
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid