Click here to Skip to main content
6,595,444 members and growing! (20,178 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » Mobile Development » Controls     Intermediate

CCeListCtrlEx for Pocket PC 2002

By Daniel Strigl

A owner drawn list control to emulate a single select list box with a little icon at the beginning of each line.
C++, eVC 3.0, Windows, PocketPC 2002, Visual Studio, MFC, Dev
Posted:14 May 2003
Views:91,020
Bookmarked:32 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
7 votes for this article.
Popularity: 3.96 Rating: 4.69 out of 5

1

2

3
2 votes, 28.6%
4
5 votes, 71.4%
5

Sample Image - CCeListCtrlEx.jpg

Introduction

Some weeks ago I tried to implement an owner drawn list box control for my Pocket PC 2002 application. I wanted to show a little icon at the beginning of each line of the list box, like Davide Calabro in his article CListBoxST, a CListBox derived control. So I decided to do this with a simple owner drawn list box control (CListBox).

I was very frustrated as I found out that the owner drawn style of the list box control is not supported under Windows CE. So I was looking for another solution and I found one. I used a simple owner drawn list control (CListCtrl) in the report style to emulate a single select list box with a little icon at the beginning of each line.

I also added some typical list box functions like GetCurSelItem and SetCurSelItem to get and set the current selected item and some functions to move an item of the list to another position. All this functions are used by the sample application, so for closer information just take a look at the source code of the sample application.

  • int GetCurSelItem() const;
  • BOOL SetCurSelItem(int nIndex);
  • BOOL MoveItem(int nOldIndex, int nNewIndex);
  • BOOL MoveItemUp(int nIndex);
  • BOOL MoveItemDown(int nIndex);
  • BOOL MoveItemTop(int nIndex);
  • BOOL MoveItemBottom(int nIndex);

The usage

The usage of the owner drawn list control (CCeListCtrlEx) is very straightforward. Just add a list control to your dialog and add a member variable from the type CCeListCtrlEx, that is assigned to the list control, to your dialog class. Don't forget to include the CeListCtrlEx.h header file.

CCeListCtrlEx m_ctrlList;

In the OnInitDialog function of your dialog, create an image list and assign it to the list control. After that you can add some items (with some little icons at the beginning of each line) to the list control.

BOOL CListCtrlTestDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    ...

    // TODO: Add extra initialization here


    ...

    // Create a image list and assign it to the list control

    VERIFY(m_imageList.Create(IDB_BITMAP1, 16, 1, RGB(255, 0, 255)));
    m_ctrlList.SetImageList(&m_imageList, LVSIL_SMALL);

    // Insert some sample items

    for (int n = 0; n < 10; n++)
    {
        CString str;
        str.Format(_T("Item %d"), n);
        m_ctrlList.InsertItem(n, str, n % 8);
    }

    ...

    return TRUE;  // return TRUE unless you set the focus to a control

}

References

The overwritten DrawItem function I was using for my owner drawn list control is based on the article "Selection Highlighting of an Entire Row", written by Uwe Keim. I used the original DrawItem function from Uwe's article and made some simple changes.

To emulate the desktop version of DrawText with the DT_END_ELLIPSIS flag set, that is not supported under Windows CE, I used the DrawTextEndEllipsis function, originally written by Alexander Shargin. You can found this function at http://www.pocketpcdn.com/qa/ellipsis_flag.html.

Release history

  • 16 May 2003

    The needed column for the list control is now created automatically (thanks to Jo�o Paulo Figueira).

  • 15 May 2003

    First release in CodeProject.

Bugs and comments

If you have any comments or find some bugs, I would love to hear about it and make it better.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Daniel Strigl


Member
Daniel Strigl is living in Austria, where he is studying Computer Science at the University of Innsbruck and working as a Software Developer at a Semiconductor Equipment Company. In his spare time he is working as a Rafting-Guide at the Outdoor Company wasser-c-raft and as a Ski- and Snowboard-Instructor at some local skischools.

His programming experience includes C/C++, C#, Java, Matlab, Assembler, MFC, DirectDraw, DirectShow, OpenGL, STL, .NET, .NET Compact Framework and a little bit HTML, JavaScript and PHP. He has worked on Microcontrollers, Texas Instruments Calculators, Texas Instruments DSPs, Pocket PCs and on PCs. His favorite development tools are Eclipse, Microsoft eMbedded Visual C++, Microsoft Visual Studio 2005, Keil uVision and Texas Instruments Code Composer Studio.

Occupation: Software Developer
Location: Austria Austria

Other popular Mobile Development articles:

  • Writing Your Own GPS Applications: Part 2
    In part two of the series, the author of "GPS.NET" teaches developers how to write GPS applications suitable for the real world by mastering GPS precision concepts. Source code includes a working NMEA interpreter and sample high-precision application in C# and VB.NET.
  • Writing Your Own GPS Applications: Part I
    What is it that GPS applications need to be good enough to use for in-car navigation? Also, how does the process of interpreting GPS data actually work? In this three-part series, I will cover both topics and give you the skills you need to write a commercial-grade GPS application.
  • Learn How to Find GPS Location on Any SmartPhone, and Then Make it Relevant
    A step by step tutorial for getting GPS from any SmartPhone, even without GPS built in, and then making location useful.
  • iPhone UI in Windows Mobile
    It's an interface that works with transparency effects. As a sample I used an interface just like the iPhone one. In this tutorial I am explaining how simple is working with transparency on Windows Mobile.
  • Pocket 1945 - A C# .NET CF Shooter
    An article on Pocket PC game development
Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 21 of 21 (Total in Forum: 21) (Refresh)FirstPrevNext
QuestionHorizontal scroll- how to lose it? Pinmemberstrelaa9:38 30 Oct '06  
GeneralProblem with with WM 5.0 Pinmemberbm_masri12:40 16 Apr '06  
GeneralSubItems PinmemberShabrawy9118:20 8 Aug '05  
GeneralArabic Problem PinmemberShabrawy91122:14 2 Aug '05  
Generalit doesn't work Pinmemberbenahpets0:15 20 Aug '04  
GeneralMultiline texts? Pinmemberrozbeh23:58 12 Mar '04  
GeneralRe: Multiline texts? PinmemberBui Huy Kien23:41 6 Sep '04  
GeneralMultiselect in a List control Pinmemberreshmasp19:53 7 Mar '04  
GeneralRe: Multiselect in a List control PinmemberDaniel S.21:19 7 Mar '04  
GeneralRe: Multiselect in a List control PinmemberDaniel S.21:46 7 Mar '04  
GeneralRe: Multiselect in a List control Pinmemberreshmasp22:17 7 Mar '04  
GeneralWhat I want to do with custom list box.. Pinmemberglenn_ford5:15 21 Jan '04  
GeneralRe: What I want to do with custom list box.. PinmemberDaniel S.9:11 21 Jan '04  
GeneralDoesn't compile uned eVC++ 3.0 Pinmemberglenn_ford5:28 20 Jan '04  
GeneralRe: Doesn't compile uned eVC++ 3.0 Pinmemberglenn_ford5:30 20 Jan '04  
GeneralRe: Doesn't compile uned eVC++ 3.0 PinmemberDaniel S.21:20 20 Jan '04  
GeneralRe: Doesn't compile uned eVC++ 3.0 Pinmemberglenn_ford5:11 21 Jan '04  
GeneralRe: Doesn't compile uned eVC++ 3.0 PinmemberM Varshney3:48 11 Oct '06  
GeneralSuggestion PinmemberJoão Paulo Figueira23:04 14 May '03  
GeneralRe: Suggestion PinsussAnonymous23:21 14 May '03  
GeneralRe: Suggestion PinmemberDaniel S.3:58 16 May '03  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 14 May 2003
Editor: Smitha Vijayan
Copyright 2003 by Daniel Strigl
Everything else Copyright © CodeProject, 1999-2009
Web17 | Advertise on the Code Project