Click here to Skip to main content
15,867,835 members
Articles / Mobile Apps / Windows Mobile

A Selection Bar for the PocketPC 2002

Rate me:
Please Sign up or sign in to vote.
4.67/5 (13 votes)
12 Mar 2003CPOL2 min read 126.7K   285   27   25
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)


Written By
Software Developer (Senior) Frotcom International
Portugal Portugal
I work on R&D for Frotcom International, a company that develops web-based fleet management solutions.

Comments and Discussions

 
QuestionPlace the indicator icon into the bar at the top of the screen Pin
Gaspard12-Nov-07 5:11
Gaspard12-Nov-07 5:11 
GeneralQuestion! Pin
kanglue17-Jul-04 5:46
kanglue17-Jul-04 5:46 
QuestionHow to add control in smart device app in c# Pin
MagdyYousif7-Apr-04 4:39
MagdyYousif7-Apr-04 4:39 
QuestionHow to hide Right menu Pin
Bui Huy Kien25-Feb-04 22:36
Bui Huy Kien25-Feb-04 22:36 
AnswerRe: How to hide Right menu Pin
João Paulo Figueira25-Feb-04 22:56
professionalJoão Paulo Figueira25-Feb-04 22:56 
GeneralRe: How to hide Right menu Pin
Bui Huy Kien26-Feb-04 17:07
Bui Huy Kien26-Feb-04 17:07 
GeneralMenu Size Pin
Tony Simmonds11-Feb-04 3:36
Tony Simmonds11-Feb-04 3:36 
GeneralRe: Menu Size Pin
João Paulo Figueira11-Feb-04 3:54
professionalJoão Paulo Figueira11-Feb-04 3:54 
QuestionHow to handle shared New button Pin
Bui Huy Kien18-Jan-04 19:36
Bui Huy Kien18-Jan-04 19:36 
Dear ,

I 'd tried to use your sample in my program but I cannot use the shared New button on the menu.

If I set m_wndCommandBar.m_bShowSharedNewButton = false;
and I add New button on the menu and handle it from CMainFrame but all other menu disappear.

Can you please show me how to handle Shared New button ?

Thank you very much.
-Kien Bui


-BHKien
AnswerRe: How to handle shared New button Pin
João Paulo Figueira18-Jan-04 22:52
professionalJoão Paulo Figueira18-Jan-04 22:52 
GeneralRe: How to handle shared New button Pin
Bui Huy Kien27-Jan-04 18:07
Bui Huy Kien27-Jan-04 18:07 
GeneralRe: How to handle shared New button Pin
João Paulo Figueira27-Jan-04 21:51
professionalJoão Paulo Figueira27-Jan-04 21:51 
GeneralRe: How to handle shared New button Pin
Bui Huy Kien27-Jan-04 22:13
Bui Huy Kien27-Jan-04 22:13 
GeneralRe: How to handle shared New button Pin
João Paulo Figueira27-Jan-04 22:36
professionalJoão Paulo Figueira27-Jan-04 22:36 
GeneralRe: How to handle shared New button Pin
Bui Huy Kien28-Jan-04 23:10
Bui Huy Kien28-Jan-04 23:10 
GeneralRe: How to handle shared New button Pin
João Paulo Figueira29-Jan-04 0:51
professionalJoão Paulo Figueira29-Jan-04 0:51 
GeneralRe: How to handle shared New button Pin
Bui Huy Kien30-Jan-04 0:50
Bui Huy Kien30-Jan-04 0:50 
GeneralAdd tooltip to the Selection Bar Pin
yttham20-May-03 5:52
yttham20-May-03 5:52 
GeneralRe: Add tooltip to the Selection Bar Pin
João Paulo Figueira20-May-03 6:08
professionalJoão Paulo Figueira20-May-03 6:08 
GeneralUsing in a Doc/View model... Pin
Anonymous31-Mar-03 3:25
Anonymous31-Mar-03 3:25 
GeneralRe: Using in a Doc/View model... Pin
João Paulo Figueira31-Mar-03 6:28
professionalJoão Paulo Figueira31-Mar-03 6:28 
GeneralRe: Using in a Doc/View model... Pin
Anonymous31-Mar-03 8:49
Anonymous31-Mar-03 8:49 
GeneralVery Nice Pin
Chopper14-Mar-03 3:57
Chopper14-Mar-03 3:57 
GeneralRe: Very Nice Pin
João Paulo Figueira14-Mar-03 4:25
professionalJoão Paulo Figueira14-Mar-03 4:25 
GeneralRe: Very Nice Pin
Roger Sager16-Apr-03 2:47
Roger Sager16-Apr-03 2:47 

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.