Copyright © 1998-1999, Kenneth M. Reed, All rights reserved.
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.
BIF_STATUSTEXT
flag to be setOnInitDialog
method
to display the initial folder in the status text.OnSelChanged
method
to update the contents of m_strFinalFolderName
and display the new folder in the status text
area.MyFolderDialog.h
file
from the zip.Please send suggestions and/or bugs to reedk@daneel.mv.com.
Ken Reed