Click here to Skip to main content
11,494,785 members (62,548 online)
Click here to Skip to main content

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

, 12 Jan 2003 CPOL 83.9K 55 27
Rate this:
Please Sign up or sign in to vote.
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)

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

 
GeneralColor change for the rows of CListViewCtrl based list for win ce O.S Pin
Bilal Ahmad22-Nov-03 3:33
memberBilal Ahmad22-Nov-03 3:33 
GeneralRe: Color change for the rows of CListViewCtrl based list for win ce O.S Pin
João Paulo Figueira22-Nov-03 8:51
memberJoão Paulo Figueira22-Nov-03 8:51 
GeneralRe: Color change for the rows of CListViewCtrl based list for win ce O.S Pin
Bilal Ahmad23-Nov-03 21:05
memberBilal Ahmad23-Nov-03 21:05 
GeneralRe: Color change for the rows of CListViewCtrl based list for win ce O.S Pin
João Paulo Figueira23-Nov-03 23:48
memberJoão Paulo Figueira23-Nov-03 23:48 
GeneralRe: Color change for the rows of CListViewCtrl based list for win ce O.S Pin
Bilal Ahmad24-Nov-03 0:56
memberBilal Ahmad24-Nov-03 0:56 
GeneralOwner draw list Pin
Idan Cohen21-Jan-03 9:56
memberIdan Cohen21-Jan-03 9:56 
GeneralRe: Owner draw list Pin
João Paulo Figueira21-Jan-03 23:19
sussJoão Paulo Figueira21-Jan-03 23:19 
GeneralRe: Owner draw list Pin
Idan Cohen22-Jan-03 1:57
memberIdan Cohen22-Jan-03 1:57 
GeneralRe: Owner draw list Pin
João Paulo Figueira22-Jan-03 2:11
memberJoão Paulo Figueira22-Jan-03 2:11 
GeneralRe: Owner draw list Pin
Idan Cohen23-Jan-03 3:17
memberIdan Cohen23-Jan-03 3:17 
GeneralRe: Owner draw list Pin
João Paulo Figueira23-Jan-03 4:25
memberJoão Paulo Figueira23-Jan-03 4:25 
GeneralRe: Owner draw list Pin
Idan Cohen23-Jan-03 13:44
memberIdan Cohen23-Jan-03 13:44 
GeneralRe: Owner draw list Pin
João Paulo Figueira23-Jan-03 23:15
memberJoão Paulo Figueira23-Jan-03 23:15 
QuestionWhy? Pin
Anonymous13-Jan-03 3:26
sussAnonymous13-Jan-03 3:26 
AnswerRe: Why? Pin
Joao Paulo Figueira13-Jan-03 4:50
memberJoao Paulo Figueira13-Jan-03 4:50 
AnswerRe: Why? Pin
João Paulo Figueira13-Jan-03 5:00
sussJoão Paulo Figueira13-Jan-03 5:00 

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
Web02 | 2.8.150520.1 | Last Updated 13 Jan 2003
Article Copyright 2003 by João Paulo Figueira
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid