Click here to Skip to main content
11,640,910 members (63,341 online)
Click here to Skip to main content

A File Open Dialog for the PocketPC 2002

, 26 Jan 2004 CPOL 239.1K 381 56
Rate this:
Please Sign up or sign in to vote.
An implementation of a full-browsing file open dialog.

Sample screenshot

Introduction

On the PocketPC, the File Open dialog is not very versatile. In fact, you are limited to a small number of directories, which may be too limiting for your own purposes. I started to think about a possible solution for this problem after reading a post in the Mobile / Embedded forum, where a reader complains about the limitations of CFileDialog.

This article describes a solution for this problem, by implementing a more advanced File Open dialog.

CFileOpenDlg

The dialog is implemented in the CFileOpenDlg class in the demo application. Its usage is very straightforward, as you can see from the sample below:

void CChildView::OnFileOpen() 
{
    CFileOpenDlg    dlg;

    if(IDOK == dlg.DoModal())
    {
        CString    strFullPath(dlg.GetPath());

        strFullPath += dlg.GetFileName();

        MessageBox(strFullPath);
    }
}

In order to get the full path name, you have to append the path and the file name, as reported by GetPath() and GetFileName().

File filters are set through the SetFilter method. By default, the dialog uses SetFilter("*"), so all files are displayed. Please note that this filter will only affect file browsing, not directory browsing.

Using The Class

Unfortunately, this class is not completely encapsulated because it needs some resources, namely the bitmaps for the list header and the dialog itself. When porting this code to your application, some cutting and pasting will be necessary. Apart from that, you will need the CExDialog and CExDlgEngine classes in order to be able to print a header in the dialog. This code is heavily based on prior art, which you can find in this article: How can I create a dialog title like in Control Panel property pages?

Limitations and Future Improvements

There are a number of limitations that will be addressed in future updates:

  • On-demand loading of the directory tree. The loading is now made in just one step and, if you have a complex directory tree, this will show in a slower operation. By loading the tree in an on-demand fashion, both start-up time and memory consumption will be greatly reduced.
  • File sorting. There is no provision for sorting files in this dialog.

Release History

26 January 2004

Third release in CodeProject with the following updates:

  • Folder tree is loaded on demand.
  • Folders use the system image list icons.
  • File list now supports sorting (ascending and descending) on any column.
  • The sorted column displays a light grey background and the header shows an arrow reflecting the sort direction.

15 May 2003

Removed references to spurious #includes and symbols.

14 May 2003

Second release in CodeProject with the following updates:

  • The device name is reported in the tree view.
  • The file list now supports file icons.
  • The OK and Cancel buttons were replaced by toolbar buttons (the cancel button is not very nice, but hey - I'm not a graphics designer)
  • Views can be switched between split view, tree view and list view.
  • You can move the split between tree and list by clicking and dragging.

27 Mar 2003

First release in CodeProject.

Thank You

Amit Dey provided the code and idea for using the system image list. Also, he provided guidance when I completely goofed the first time I tried it.

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.

You may also be interested in...

Comments and Discussions

 
Questionhow to run .ppt file on smartdevice application Pin
Member 412018925-Sep-08 0:38
memberMember 412018925-Sep-08 0:38 
GeneralMak it work across a LAN Pin
jima2z6-Jan-07 4:22
memberjima2z6-Jan-07 4:22 
Generalshell open command Pin
M i s t e r L i s t e r17-Oct-06 18:02
memberM i s t e r L i s t e r17-Oct-06 18:02 
GeneralCode ported to PPC2003 and WM5 under VS2005 [modified] Pin
Vincent_RICHOMME10-Aug-06 7:38
memberVincent_RICHOMME10-Aug-06 7:38 
GeneralRe: Code ported to PPC2003 and WM5 under VS2005 Pin
JasonHo24-Aug-06 1:32
memberJasonHo24-Aug-06 1:32 
QuestionRe: Code ported to PPC2003 and WM5 under VS2005 Pin
goddamnelectric9-Jan-07 23:06
membergoddamnelectric9-Jan-07 23:06 
GeneralRe: Code ported to PPC2003 and WM5 under VS2005 Pin
noob_the_penguin7-Jun-07 1:32
membernoob_the_penguin7-Jun-07 1:32 
GeneralRe: Code ported to PPC2003 and WM5 under VS2005 Pin
Vincent_RICHOMME7-Jun-07 11:31
memberVincent_RICHOMME7-Jun-07 11:31 
GeneralFileOpen2: A Command Line Version [modified] Pin
NaviGer27-May-06 0:23
memberNaviGer27-May-06 0:23 
Questionanyone ported this to VS 2005? Pin
miggedy21-Mar-06 17:12
membermiggedy21-Mar-06 17:12 
AnswerRe: anyone ported this to VS 2005? Pin
Vincent_RICHOMME10-Aug-06 7:39
memberVincent_RICHOMME10-Aug-06 7:39 
QuestionManaged Code Equivalent of this? Pin
Vasudevan Deepak Kumar14-Mar-06 4:10
memberVasudevan Deepak Kumar14-Mar-06 4:10 
AnswerRe: Managed Code Equivalent of this? Pin
João Paulo Figueira14-Mar-06 4:16
memberJoão Paulo Figueira14-Mar-06 4:16 
GeneralSaving Bitmaps in WinCE Pin
Justin Clayden12-Dec-05 16:01
memberJustin Clayden12-Dec-05 16:01 
QuestionCan I use that on my (GLP) project? Pin
haamsteer17-Oct-05 9:10
memberhaamsteer17-Oct-05 9:10 
what terms of use/distribuition must I know? can I make my own changes? Can I redistribute those changes as DLL (including a mention about the original author)?

AnswerRe: Can I use that on my (GLP) project? Pin
João Paulo Figueira17-Oct-05 11:18
memberJoão Paulo Figueira17-Oct-05 11:18 
GeneralRe: Can I use that on my (GLP) project? Pin
franprak6-Mar-07 17:35
memberfranprak6-Mar-07 17:35 
GeneralRe: Can I use that on my (GLP) project? Pin
João Paulo Figueira6-Mar-07 22:59
memberJoão Paulo Figueira6-Mar-07 22:59 
QuestionCan not found Deque.h Pin
lvguangchuan6-Oct-05 11:21
memberlvguangchuan6-Oct-05 11:21 
AnswerRe: Can not found Deque.h Pin
João Paulo Figueira6-Oct-05 12:18
memberJoão Paulo Figueira6-Oct-05 12:18 
GeneralRe: Can not found Deque.h Pin
NaviGer21-May-06 5:48
memberNaviGer21-May-06 5:48 
GeneralRe: Can not found Deque.h Pin
NaviGer21-May-06 5:52
memberNaviGer21-May-06 5:52 
GeneralRe: Can not found Deque.h Pin
João Paulo Figueira21-May-06 6:16
memberJoão Paulo Figueira21-May-06 6:16 
GeneralRe: Can not found Deque.h [modified] Pin
Andy Byron28-Sep-06 7:14
memberAndy Byron28-Sep-06 7:14 
GeneralSmall improvements Pin
Dmitry Yakimov18-Aug-05 5:53
sussDmitry Yakimov18-Aug-05 5:53 
GeneralRe: Small improvements Pin
João Paulo Figueira18-Aug-05 5:56
memberJoão Paulo Figueira18-Aug-05 5:56 
GeneralRe: Small improvements Pin
Dmitry Yakimov18-Aug-05 6:11
sussDmitry Yakimov18-Aug-05 6:11 
GeneralRe: Small improvements Pin
Dmitry Yakimov18-Aug-05 6:13
sussDmitry Yakimov18-Aug-05 6:13 
QuestionBrowsing desktop computer? Pin
george ivanov17-May-05 20:47
membergeorge ivanov17-May-05 20:47 
AnswerRe: Browsing desktop computer? Pin
João Paulo Figueira17-May-05 21:44
memberJoão Paulo Figueira17-May-05 21:44 
QuestionHow to sort treeview? Pin
Roger Sager11-Nov-04 1:33
memberRoger Sager11-Nov-04 1:33 
AnswerRe: How to sort treeview? Pin
João Paulo Figueira11-Nov-04 6:48
memberJoão Paulo Figueira11-Nov-04 6:48 
Generalnon-STL version w/code Pin
tim234229-Oct-04 12:55
membertim234229-Oct-04 12:55 
GeneralRe: non-STL version w/code Pin
João Paulo Figueira30-Oct-04 4:54
memberJoão Paulo Figueira30-Oct-04 4:54 
Questionhow to show image by clicking on button using VB 6 Pin
mai nageeb5-Oct-04 2:50
sussmai nageeb5-Oct-04 2:50 
GeneralWould be useful, however... Pin
hw7704118-Jul-04 10:09
memberhw7704118-Jul-04 10:09 
GeneralRe: Would be useful, however... Pin
João Paulo Figueira19-Jul-04 11:30
memberJoão Paulo Figueira19-Jul-04 11:30 
GeneralRe: Would be useful, however... Pin
hw7704119-Jul-04 11:56
memberhw7704119-Jul-04 11:56 
GeneralRe: Would be useful, however... Pin
pshsla5-Feb-05 5:44
memberpshsla5-Feb-05 5:44 
GeneralRe: Would be useful, however... Pin
hw770415-Feb-05 12:34
memberhw770415-Feb-05 12:34 
GeneralRe: Would be useful, however... Pin
Daniel Jin6-Apr-05 4:16
memberDaniel Jin6-Apr-05 4:16 
GeneralBrowse network (get content of remoute computer) Pin
neostar11-Jun-04 6:12
memberneostar11-Jun-04 6:12 
Generalnon-GUI drive reader Pin
auburnate26-May-04 6:05
memberauburnate26-May-04 6:05 
GeneralRe: non-GUI drive reader Pin
João Paulo Figueira26-May-04 6:42
memberJoão Paulo Figueira26-May-04 6:42 
GeneralDateTimeFormat question(s) Pin
Jens Olsson5-Apr-04 23:51
memberJens Olsson5-Apr-04 23:51 
GeneralRe: DateTimeFormat question(s) Pin
João Paulo Figueira6-Apr-04 3:48
memberJoão Paulo Figueira6-Apr-04 3:48 
GeneralRe: DateTimeFormat question(s) Pin
Jens Olsson6-Apr-04 4:38
memberJens Olsson6-Apr-04 4:38 
GeneralRe: DateTimeFormat question(s) Pin
João Paulo Figueira6-Apr-04 14:43
memberJoão Paulo Figueira6-Apr-04 14:43 
GeneralWin32 Pin
sedwo27-Mar-04 10:12
membersedwo27-Mar-04 10:12 
GeneralRe: Win32 Pin
João Paulo Figueira28-Mar-04 0:01
memberJoão Paulo Figueira28-Mar-04 0:01 

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