Click here to Skip to main content
15,884,353 members
Articles / Mobile Apps / Windows Mobile

A quick way of implementing a Pocket Outlook - type letter strip

Rate me:
Please Sign up or sign in to vote.
4.33/5 (3 votes)
12 Jan 2003CPOL2 min read 100.4K   72   27   16
Implementing a letter strip control for record selection.

Sample Image - CLetterStrip.jpg

Introduction

This article presents a very quick implementation of the "Letter Strip" control found in Pocket Outlook. It is a very simple control that allows the user to select or find the information on a list, by clicking on one of the nine letter areas. The behavior that Pocket Outlook implements is to find all the records that start with the given letter. To choose another letter in the same group, the user clicks the same area, and the control loops in a circular fashion through all three letters.

Implementation

This is a "quick and dirty" implementation of the control in MFC. It is so quick and dirty that the image of the strip is a bitmap that was acquired through Remote Zoomin. I hope this means no copyright infringement...

As for the "control" itself, it is a CWnd-derived class that paints itself with the bitmap. As you will see, this means that the control is not self-contained, because it depends on an externally provided bitmap resource ID (it is very easy to go around this).

Using the CLetterStrip class

In order to use the CLetterStrip class, you only need to include the header file, and create the window, using:

BOOL Create(DWORD dwStyle, CPoint pt, CWnd *pParentWnd, UINT nID);

For instance:

dwStyle = WS_CHILD | WS_VISIBLE;
m_wndStrip.Create(dwStyle, CPoint(0, 0), pParentWnd, ID_LETTERSTRIP);

When the user clicks the strip, it will calculate the appropriate letter, and will report to its parent window, an ON_COMMAND message. The handling is typically:

ON_COMMAND(ID_LETTERSTRIP, OnLetterStrip)

When handling the command, you query the selected letter like:

TCHAR szLetter[2] = {0, 0};

szLetter[0] = m_wndStrip.GetOption();

Limitations and future enhancements

Well, this is a very simple implementation of the control. As I said before, it is not self-contained and this may well be a nuisance. Reporting the selected letter is made through an MFC call. In future versions, the window will support a message to return the selected letter. The control provides no positive feedback (just like the one in Pocket Outlook). A sound message can be included, but a really nice feature would be to provide immediate visual feedback. This would be done by drawing the selected letter in a different color. Well, that would mean dropping the bitmap nonsense as well and drawing the whole thing (and then it would also be self-contained, as well). Finally, this has NOT been tested with dialogs.

Nevertheless, I'm publishing this measly piece of code because it is already working for me. So why shouldn't it work for you as well? (You can always wait for the next version...)

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

 
GeneralColor change for the rows of CListViewCtrl based list for win ce O.S Pin
Bilal Ahmad22-Nov-03 2:33
Bilal Ahmad22-Nov-03 2:33 
GeneralRe: Color change for the rows of CListViewCtrl based list for win ce O.S Pin
João Paulo Figueira22-Nov-03 7:51
professionalJoão Paulo Figueira22-Nov-03 7:51 
GeneralRe: Color change for the rows of CListViewCtrl based list for win ce O.S Pin
Bilal Ahmad23-Nov-03 20:05
Bilal Ahmad23-Nov-03 20:05 
GeneralRe: Color change for the rows of CListViewCtrl based list for win ce O.S Pin
João Paulo Figueira23-Nov-03 22:48
professionalJoão Paulo Figueira23-Nov-03 22:48 
GeneralRe: Color change for the rows of CListViewCtrl based list for win ce O.S Pin
Bilal Ahmad23-Nov-03 23:56
Bilal Ahmad23-Nov-03 23:56 
GeneralOwner draw list Pin
Idan Cohen21-Jan-03 8:56
Idan Cohen21-Jan-03 8:56 
GeneralRe: Owner draw list Pin
João Paulo Figueira21-Jan-03 22:19
professionalJoão Paulo Figueira21-Jan-03 22:19 
GeneralRe: Owner draw list Pin
Idan Cohen22-Jan-03 0:57
Idan Cohen22-Jan-03 0:57 
GeneralRe: Owner draw list Pin
João Paulo Figueira22-Jan-03 1:11
professionalJoão Paulo Figueira22-Jan-03 1:11 
GeneralRe: Owner draw list Pin
Idan Cohen23-Jan-03 2:17
Idan Cohen23-Jan-03 2:17 
GeneralRe: Owner draw list Pin
João Paulo Figueira23-Jan-03 3:25
professionalJoão Paulo Figueira23-Jan-03 3:25 
GeneralRe: Owner draw list Pin
Idan Cohen23-Jan-03 12:44
Idan Cohen23-Jan-03 12:44 
GeneralRe: Owner draw list Pin
João Paulo Figueira23-Jan-03 22:15
professionalJoão Paulo Figueira23-Jan-03 22:15 
QuestionWhy? Pin
Anonymous13-Jan-03 2:26
Anonymous13-Jan-03 2:26 
AnswerRe: Why? Pin
João Paulo Figueira13-Jan-03 3:50
professionalJoão Paulo Figueira13-Jan-03 3:50 
AnswerRe: Why? Pin
João Paulo Figueira13-Jan-03 4:00
professionalJoão Paulo Figueira13-Jan-03 4:00 

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.