MFC Wrapper for SHBrowseForFolder
Description
CFolderDialog is an MFC based class that
encapsulates the Windows Shell function for browsing folders, ::ShBrowseForFolder.
To use it, you create an instance of CFolderDialog
and call the DoModal method. Upon return, the method
GetPathName can be used to retrieve the path to the
user selected folder.
The constructor allows you to specify an optional initial
folder, flags specific to the shell function (see the description
of the ulFlags field of the BROWSEINFO structure
in the help for Visual Studio or the Windows Shell API) and a
pointer to the parent windows CWnd. All of
these arguments are optional.
You may override the two virtual methods OnInitDialog
and OnSelChanged in a derived class to customize
their behavior. The default behavior of OnInitDialog
is to call SetSelection and SetStatusText
with the folder name provided in the constructor. The default
version of OnSelChanged places the new path into the
status text area of the dialog.
The class provides utility functions for 1) enabling or
disabling the OK button (EnableOK), 2) setting the
status text that appears above the folder list box in the browser
folder dialog box (SetStatusText) and 3) setting the
current selection (SetSelection). The file MyFolderDialog.h,
included in the zip file, shows an example of a derived class
which uses SetStatusText.
For advanced users, the BROWSEINFO structure is
available via the m_bi member variable. This
structure is initialized by the constructor and any changes
should be made before the call to DoModal. See the help for
Visual Studio or the Windows Shell API for more information on
the BROWSEINFO structure.
The zip file also contains the source for CMyFolderDialog, a class derived from CFolderDialog to show how to take advantage of some of the advanced features.
Revisions
- December 29, 1998
- Added the CMyFolderDialog source code the version available on the codeguru site.
- June 23, 1998
- Fixed a problem in EnableOK. The documenation for the
SHBrowseForFolder call back incorrectly states that it is
the wParam on the BFFM_ENABLEOK message which controls
the enabling/disabling of the OK button. However, It is
actually the lParam.
Thanks to Langis Pitre for finding this one. - April 5, 1998
- Changed the way status text is handled:
- The constructor now forces the
BIF_STATUSTEXTflag to be set - Changed the base
OnInitDialogmethod to display the initial folder in the status text. - Changed the base
OnSelChangedmethod to update the contents of m_strFinalFolderName and display the new folder in the status text area. - Removed the
MyFolderDialog.hfile from the zip.
- The constructor now forces the
Bugs and Suggestions
Please send suggestions and/or bugs to reedk@daneel.mv.com.
Ken Reed
Download source code - 6 KBDate Last Updated: February 3, 1999

Comments
Nike Wind Max+instagram, at one's desire you take the color to be in on your feet!
Posted by madytreathy on 04/21/2013 08:10pmRemember in 2008, if not earlier, when Nike launched on of the independent shoe color projects, the watchword "Bound Your Colours", "Nike PhotoiD" layout, [url=http://northernroofing.co.uk/roofins.cfm]nike free run uk[/url] response has not been as avid as expected. About, 2008 Canon IXUS 80 IS Digital greetings card arcade but contrariwise 8 million pixels, Nokia, the motorized phone market is the one regulation, NikeiD was support to color in the photos as a essence for sneakers custom color, although interesting, but does provoke some. Instagram which communicate this passion fun and elemental, Nike PHOTOiD homeopathic upgrade customization services, recently [url=http://markwarren.org.uk/goodbuy.cfm]nike free uk[/url] released a unique plan. That such iD can you utensil pictures as instagram account shoe color, little while offer Nike Breeze Max shoes and Nike Refresh Max 1, Nike Feeling Max 90 953 options. Interested in children's shoes, you [url=http://fossilsdirect.co.uk/glossarey.cfm]nike huarache[/url] can always vanish into thin air's official website photoid.Nike.com, in addition to flick through other people's ingenious sweat, or you can hear to upload your own instagram photo, erect your own Nike Hauteur Max.
ReplyThanks, works great.
Posted by porphyrula on 03/07/2007 03:20pmThanks, you saved me a lot of time and bother.
Replyexactly what i needed, but...
Posted by mensch on 09/14/2005 11:09pmu might want to add this in somewhere if you want to pause the application while browsing, modify the m_bi.hwndOwner value to a non-zero value, then call domodal
ReplyNifty!
Posted by Legacy on 06/08/2003 12:00amOriginally posted by: Mohamed Mustafa
i used this in 2k, it soves the purpose. thanx
ReplyMemory leak somewhere :((
Posted by Legacy on 04/03/2003 12:00amOriginally posted by: Dmitry
This is what I got from VS.NET:
Detected memory leaks!
Dumping objects ->
{97} normal block at 0x00A971D8, 20 bytes long.
Data: < ~^ > 08 7E 5E 00 03 00 00 00 03 00 00 00 01 00 00 00
{96} normal block at 0x00A97188, 20 bytes long.
Data: < ~^ > 08 7E 5E 00 03 00 00 00 03 00 00 00 01 00 00 00
{95} normal block at 0x00A96F10, 568 bytes long.
Data: <4 Y <o > 34 B0 59 00 94 04 0B 00 00 00 00 00 3C 6F A9 00
Object dump complete.
Any idea what the reason of leaks?
Thanks
ReplyGood Class
Posted by Legacy on 09/25/2001 12:00amOriginally posted by: LBD
Very useful class. Is it free to the general public for use in applications as long as the copyright notices are maintained?
ReplyTHX a lot
Posted by Legacy on 09/17/2001 12:00amOriginally posted by: Jan
Thx for this class.
I've spent days with searching an object of MFC to do this.
Unbelievable that something like that isn't included to MFC.
ReplyBrowse for folder
Posted by Legacy on 09/08/2001 12:00amOriginally posted by: Johnny Olsen
Thanks for your code.
I've already made the same in Delphi some years ago,
but now I needed it in Visual C++.
Of course I was possible for me to copy the functionality,
from the Delphi code, but it is somewhat faster, just to
include your classes directly in the application.
Kind regards
ReplyJohnny
please help !!
Posted by Legacy on 04/20/2001 12:00amOriginally posted by: Baba
I find this wrapper very interesting...but I want to display both folders and files.
I tried the use of the BIF_BROWSEINCLUDEFILES flag but it don't work!!
Do any one get an idea for me? thanks!
ReplyAnother feature -> Function to set the root path
Posted by Legacy on 02/22/2000 12:00amOriginally posted by: Jose Insa
ReplyLoading, Please Wait ...