Click here to Skip to main content
Licence CPOL
First Posted 12 Jan 2003
Views 79,262
Downloads 36
Bookmarked 26 times

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

By | 12 Jan 2003 | Article
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)

About the Author

Joao Paulo Figueira

Software Developer
Primeworks
Portugal Portugal

Member

João is a partner at Primeworks, a company that develops remote database access software for Windows Mobile. He also works for Frotcom, a company that develops web-based fleet management solutions.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralColor change for the rows of CListViewCtrl based list for win ce O.S PinmemberBilal Ahmad2:33 22 Nov '03  
GeneralRe: Color change for the rows of CListViewCtrl based list for win ce O.S PinmemberJoão Paulo Figueira7:51 22 Nov '03  
GeneralRe: Color change for the rows of CListViewCtrl based list for win ce O.S PinmemberBilal Ahmad20:05 23 Nov '03  
GeneralRe: Color change for the rows of CListViewCtrl based list for win ce O.S PinmemberJoão Paulo Figueira22:48 23 Nov '03  
GeneralRe: Color change for the rows of CListViewCtrl based list for win ce O.S PinmemberBilal Ahmad23:56 23 Nov '03  
GeneralOwner draw list PinmemberIdan Cohen8:56 21 Jan '03  
GeneralRe: Owner draw list PinsussJoão Paulo Figueira22:19 21 Jan '03  
GeneralRe: Owner draw list PinmemberIdan Cohen0:57 22 Jan '03  
GeneralRe: Owner draw list PinmemberJoão Paulo Figueira1:11 22 Jan '03  
GeneralRe: Owner draw list PinmemberIdan Cohen2:17 23 Jan '03  
GeneralRe: Owner draw list PinmemberJoão Paulo Figueira3:25 23 Jan '03  
GeneralRe: Owner draw list PinmemberIdan Cohen12:44 23 Jan '03  
GeneralRe: Owner draw list PinmemberJoão Paulo Figueira22:15 23 Jan '03  
QuestionWhy? PinsussAnonymous2:26 13 Jan '03  
AnswerRe: Why? PinmemberJoao Paulo Figueira3:50 13 Jan '03  
AnswerRe: Why? PinsussJoão Paulo Figueira4:00 13 Jan '03  

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.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120528.1 | Last Updated 13 Jan 2003
Article Copyright 2003 by Joao Paulo Figueira
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid