Click here to Skip to main content
15,879,613 members
Articles / Mobile Apps / Windows Mobile

A File Open Dialog for the PocketPC 2002

Rate me:
Please Sign up or sign in to vote.
4.86/5 (34 votes)
26 Jan 2004CPOL3 min read 287.4K   457   56   113
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)


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

 
GeneralRe: Win32 Pin
sedwo6-Apr-04 19:08
sedwo6-Apr-04 19:08 
Questionhow to select directory only Pin
SCSB Gang4-Feb-04 1:23
SCSB Gang4-Feb-04 1:23 
AnswerRe: how to select directory only Pin
João Paulo Figueira4-Feb-04 1:42
professionalJoão Paulo Figueira4-Feb-04 1:42 
Generalcannot find deque.h Pin
HydGuy29-Jan-04 18:46
HydGuy29-Jan-04 18:46 
GeneralRe: cannot find deque.h Pin
João Paulo Figueira29-Jan-04 22:18
professionalJoão Paulo Figueira29-Jan-04 22:18 
GeneralRe: Thank You It Worked Pin
HydGuy1-Feb-04 17:48
HydGuy1-Feb-04 17:48 
GeneralRe: Thank You It Worked Pin
João Paulo Figueira1-Feb-04 22:44
professionalJoão Paulo Figueira1-Feb-04 22:44 
QuestionCan this be built for Pocket PC 2003? Pin
nayak22-Jan-04 11:28
nayak22-Jan-04 11:28 
AnswerRe: Can this be built for Pocket PC 2003? Pin
João Paulo Figueira22-Jan-04 11:47
professionalJoão Paulo Figueira22-Jan-04 11:47 
GeneralRe: Can this be built for Pocket PC 2003? Pin
nayak23-Jan-04 4:24
nayak23-Jan-04 4:24 
GeneralRe: Can this be built for Pocket PC 2003? Pin
User 4864828-Jan-04 21:44
User 4864828-Jan-04 21:44 
GeneralRe: Can this be built for Pocket PC 2003? Pin
Jason_Hsu30-May-05 23:50
Jason_Hsu30-May-05 23:50 
QuestionCan u please help me? Pin
pjp_eee22-Jan-04 2:41
susspjp_eee22-Jan-04 2:41 
AnswerHai got it! Pin
P_JAYAPRAKASH22-Jan-04 3:15
P_JAYAPRAKASH22-Jan-04 3:15 
GeneralExcellent Work Pin
P_JAYAPRAKASH22-Jan-04 1:52
P_JAYAPRAKASH22-Jan-04 1:52 
GeneralRe: Excellent Work Pin
João Paulo Figueira22-Jan-04 2:29
professionalJoão Paulo Figueira22-Jan-04 2:29 
GeneralRe: Excellent Work Pin
P_JAYAPRAKASH22-Jan-04 3:02
P_JAYAPRAKASH22-Jan-04 3:02 
GeneralI need ur help!!! Pin
pjp_eee13-Jan-04 20:05
susspjp_eee13-Jan-04 20:05 
GeneralRe: I need ur help!!! Pin
João Paulo Figueira13-Jan-04 22:21
professionalJoão Paulo Figueira13-Jan-04 22:21 
Questionsorting....when will it be up? Pin
Amit Dey27-Dec-03 14:49
Amit Dey27-Dec-03 14:49 
AnswerRe: sorting....when will it be up? Pin
João Paulo Figueira28-Dec-03 0:19
professionalJoão Paulo Figueira28-Dec-03 0:19 
GeneralOnce again... Pin
#realJSOP30-Oct-03 5:20
mve#realJSOP30-Oct-03 5:20 
GeneralRe: Once again... Pin
João Paulo Figueira30-Oct-03 5:23
professionalJoão Paulo Figueira30-Oct-03 5:23 
GeneralCrashing on ::SHGetFileInfo in x86 debug Pin
Member 21726611-Aug-03 13:55
Member 21726611-Aug-03 13:55 
GeneralRe: Crashing on ::SHGetFileInfo in x86 debug Pin
João Paulo Figueira11-Aug-03 21:31
professionalJoão Paulo Figueira11-Aug-03 21:31 

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.