Click here to Skip to main content
Click here to Skip to main content

A Selection Bar for the PocketPC 2002

, 12 Mar 2003 CPOL
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

Introduction

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.

CCeSelectBar

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.

License

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

Share

About the Author

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

Comments and Discussions

 
GeneralVery Nice PinmemberChopper14-Mar-03 4:57 
GeneralRe: Very Nice PinmemberJoão Paulo Figueira14-Mar-03 5:25 
GeneralRe: Very Nice PinmemberRoger Sager16-Apr-03 3:47 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 13 Mar 2003
Article Copyright 2003 by João Paulo Figueira
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid