Click here to Skip to main content
Licence CPOL
First Posted 26 Mar 2003
Views 206,804
Downloads 171
Bookmarked 54 times

A File Open Dialog for the PocketPC 2002

By Joao Paulo Figueira | 26 Jan 2004
An implementation of a full-browsing file open dialog.

1

2
1 vote, 2.9%
3
4 votes, 11.8%
4
29 votes, 85.3%
5
4.86/5 - 34 votes
1 removed
μ 4.68, σa 0.80 [?]

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)

About the Author

Joao Paulo Figueira

Software Developer
Primeworks
Portugal Portugal

Member
João is a Microsoft Device Application Development MVP and partner at Primeworks, a company that develops remote database access software for Windows Mobile.

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
Questionhow to run .ppt file on smartdevice application PinmemberMember 41201891:38 25 Sep '08  
GeneralMak it work across a LAN Pinmemberjima2z5:22 6 Jan '07  
Generalshell open command PinmemberM i s t e r L i s t e r19:02 17 Oct '06  
GeneralCode ported to PPC2003 and WM5 under VS2005 [modified] PinmemberVincent_RICHOMME8:38 10 Aug '06  
Hi,
 
I have ported this code to WM5 under VS2005 and I think it may be interesting to share it with you. For now I have implemented it quickly without taking in account portability with PPC2002. I am rewriting it cleaner and I will post the code today on tomorrow.
 
UPDATE : I won't have time to keep compatibility with PPC2002 so I am posting the source code. You can find it at CeFileOpenDlg_VS2005_UPDATED.zip
Juste note that it works ONLY with MFC in static. To get it to work with MFC as dll you need to rebuild a VS2005 project from scratch because I think that conversion from eVC project is not perfect.
 
For people interested, main difference was related to command bar. With PPC2003 and WM5 CCeCommandBar has been replaced by CCommandBar and you need to handle toolbar creation.
I have replaced

BOOL CFileOpenDlg::OnInitDialog()
{
...
 
//
// Create the toolbar
//
m_pCmdBar = (CCommandBar*)m_pWndEmptyCB;
m_pCmdBar->LoadToolBar(IDR_FILEOPEN);
 
by
if(!m_wndCommandBar.Create(this) ||
!m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
!m_wndCommandBar.AddAdornments() ||
!m_wndCommandBar.LoadToolBar(IDR_FILEOPEN))
{
TRACE0("Failed to create CommandBar\n");
return -1; // fail to create
}
...

 
REMOVE from MainFrm.h
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
 
REPLACE
#if defined(_WIN32_WCE_PSPC) && (_WIN32_WCE >= 212)
By
#if _WIN32_WCE >= 212
 

 
remove DS_MODALFRAME from windows style
 

In linker settings you also need to replace wWinMainCRTStartup by WinMainCRTStartup(without w before).
 

GeneralRe: Code ported to PPC2003 and WM5 under VS2005 PinmemberJasonHo2:32 24 Aug '06  
QuestionRe: Code ported to PPC2003 and WM5 under VS2005 Pinmembergoddamnelectric0:06 10 Jan '07  
GeneralRe: Code ported to PPC2003 and WM5 under VS2005 Pinmembernoob_the_penguin2:32 7 Jun '07  
GeneralRe: Code ported to PPC2003 and WM5 under VS2005 PinmemberVincent_RICHOMME12:31 7 Jun '07  
GeneralFileOpen2: A Command Line Version [modified] PinmemberNaviGer1:23 27 May '06  
Questionanyone ported this to VS 2005? Pinmembermiggedy18:12 21 Mar '06  
AnswerRe: anyone ported this to VS 2005? PinmemberVincent_RICHOMME8:39 10 Aug '06  
QuestionManaged Code Equivalent of this? PinmemberVasudevan Deepak Kumar5:10 14 Mar '06  
AnswerRe: Managed Code Equivalent of this? PinmemberJoão Paulo Figueira5:16 14 Mar '06  
GeneralSaving Bitmaps in WinCE PinmemberJustin Clayden17:01 12 Dec '05  
QuestionCan I use that on my (GLP) project? Pinmemberhaamsteer10:10 17 Oct '05  
AnswerRe: Can I use that on my (GLP) project? PinmemberJoão Paulo Figueira12:18 17 Oct '05  
GeneralRe: Can I use that on my (GLP) project? Pinmemberfranprak18:35 6 Mar '07  
GeneralRe: Can I use that on my (GLP) project? PinmemberJoão Paulo Figueira23:59 6 Mar '07  
QuestionCan not found Deque.h Pinmemberlvguangchuan12:21 6 Oct '05  
AnswerRe: Can not found Deque.h PinmemberJoão Paulo Figueira13:18 6 Oct '05  
GeneralRe: Can not found Deque.h PinmemberNaviGer6:48 21 May '06  
GeneralRe: Can not found Deque.h PinmemberNaviGer6:52 21 May '06  
GeneralRe: Can not found Deque.h PinmemberJoão Paulo Figueira7:16 21 May '06  
GeneralRe: Can not found Deque.h [modified] PinmemberAndy Byron8:14 28 Sep '06  
GeneralSmall improvements PinsussDmitry Yakimov6:53 18 Aug '05  

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.120210.1 | Last Updated 27 Jan 2004
Article Copyright 2003 by Joao Paulo Figueira
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid