![]() |
Platforms, Frameworks & Libraries »
MFC »
General
Intermediate
License: The Code Project Open License (CPOL)
SelectDialog - A Multiple File and Folder Select DialogBy Hojjat BohlooliA multi select files and folders browse window |
VC6, VC7, VC7.1, VC8.0Win2K, WinXP, Win2003, Vista, MFC
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
It has probably happened that you need a dialog like CFileDialog (MFC) that allows you to select some items together. I do not mean multi select file feature but multi select files and folders.
If you search MSDN and the internet for libraries which do that for you, maybe the best things you would find are CFileDialog for selecting single or multiple files and SHBrowseForFolder API for selecting a single folder.
So the problem is that you need a utility that makes it possible to select every browsable thing.
If you want to have a single class using it you can select a file or a folder or some files or some folders or a mixture of them. I searched for such a utility but found nothing. So I decided to provide it and the best solution that I found was changing CFileDialog to do what I need.
CSelectDialog is a class that is inherited from CFileDialog and makes it possible for you to browse your computer or network and select a mixture of files and folders. For my convenience (as implementer) and user, I add a member of type CStringArray to the class to keep selected items after dialog returns IDOK.
OnInitDone, OnFolderChange, OnFileNameOK and WndProc functions of CFileDialog are overridden in CSelectDialog. Use of CSelectDialog is similar to CFileDialog. Simply define a variable of type CSelectDialog and DoModal it. After user clicks the OK button, you can access the full path of selected items via m_lstSelectedItems member. A code snippet that does this work is shown below:
CSelectDialog ofd(TRUE, _T("*.*"), NULL,
OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT,
_T("All files and folders(*.*)|*.*||") );
if( ofd.DoModal() != IDOK )
return;
for( int i=0; i<ofd.m_SelectedItemList.GetCount(); i++ )
m_lstSelectedItems.AddString( ofd.m_SelectedItemList[i] );
If you want to disable multi select, you should make a change in CSelectDialog constructor.
If you want to hide a combobox and its label below select dialog, you should uncomment 2 lines below in OnInitDone function:
...
//HideControl(cmb13);
//HideControl(stc3);
...
For prevention of exception in XP SP3, you should comment all lines containing cmb13 in OnInitDone function.
When I searched the Internet, nobody provided such a browse dialog with this feature.
SelectDialog | You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 26 Dec 2008 Editor: Deeksha Shenoy |
Copyright 2008 by Hojjat Bohlooli Everything else Copyright © CodeProject, 1999-2009 Web19 | Advertise on the Code Project |