Code Protection and Obfuscator For .Net, Licensing And Copy Protection for .Net, ActiveX and MFC

SHBrowseForFolder Unmasked: Everything You Wanted To Know About The Windows Folder Browser Component

Introduction
Basic Usage
Advanced Usage
Limitations
Beyond SHBrowseForFolder - The FolderView Control

Introduction

The SHBrowseForFolder Windows API function provides a folder browser component for your MFC/ATL/C++ and VB6 applications. The UI consists of a modal dialog which contains a tree control displaying all the files and folders on the system. The user can then browse and select a folder from the tree. The full path of the selected folder is then returned.

Basic Usage

To display a folder explorer UI to the user, the SHBrowseForFolder function is called. This shows the modal dialog containing the folder browser control (tree) and an OK and Cancel button. If the user selects a folder and clicks the OK button, the ShowDialog method returns a PIDL representing the folder selected. If the user clicks the Cancel button, a NULL value is returned.

Advanced Usage

The SHBrowseForFolder has some additional features such as limiting the view of the file system that is displayed to the user and displaying a button to allow the user to create a new folder.

The folder explorer control's root folder can be set to the full path of the folder which is to be displayed as the root of the tree control of the folder browser component. For example, only folders from the 'My Documents' folder can be displayed in the tree, so the user can only select 'My Documents' or its sub-folders.

The folder browser dialog can also be made to show a 'New Folder' button, in addition to the folder explorer tree control, and the OK and Cancel buttons. When it is clicked, it creates a new folder under the currently selected folder.


FolderBrowserDialog Developed Using FolderView Control Showing Files As Well As Folders.


FolderBrowserDialog Developed Using FolderView Control Showing Multi-State Check Boxes


FolderBrowserDialog Developed Using FolderView Control Showing Multiple Root Nodes.

FolderBrowserDialog Developed Using FolderView Control Showing Custom Context Menu Items.

FolderBrowserDialog Developed Using FolderView Control With Appearance Completely Changed.


FolderBrowserDialog Developed Using FolderView Control Showing Custom/Virtual Items (Non-Files/Folders)
More Screenshots

 

Limitations

While the folder browser component is a handy way to allow the users to browse and select folders, it suffers from many limitations, some of them preventing the component from being of practical use in applications.

Modal Functionality

The most visible drawback of the folder browser component is that it displays its UI in the form of a modal dialog. When shown, it blocks the rest of the application until the user has chosen a folder. As long as the dialog is displayed, no input (keyboard or mouse click) can occur except within the dialog box. The user must click the OK or Cancel button before input to the calling program can occur.

This is a very annoying and limiting feature of the folder browser dialog. Users are very likely to be irritated and annoyed when they have to interact with a modal dialog every time they have to explore and select a folder. A non-modal UI control which can be put inside of one of the applications's own forms or dialogs is a much more user-friendly way of displaying the same UI.

No Multiple Selection

The folder browser component does not allow multiple folders to be selected.

No Check Boxes

The folder explorer tree in the folder browser dialog cannot show check boxes next to nodes. Ability to show multi-state check boxes can be a very handle feature for such a control.

No Filtering

The folder browser control has no support for filtering. For example, it is not possible to display only network folders or only shared folders or only folders starting with the string "Documents" or files having a particular extension.

No Custom Controls

When using the folder browser component, you are only limited to the actual folder explorer tree control, the OK, Cancel and New Folder buttons and the description label. It is not possible to add custom controls to the dialog box. This can be useful in many circumstances such as when you want to show a thumbnail/preview of the selected file/folder or any kind of additional information.

No Appearance Control

The appearance of the folder browser dialog and its constituent controls cannot be changed. Neither can attributes of individual folders show in the folder explorer control be changed. For example, it is not possible to change the background color of the tree control or to set the font and color of individual nodes/folders in the tree.

No Custom items

The folder browser dialog cannot display external/custom items in the folder explorer tree. For example, it may be necessary to display items from an FTP location in addition to the file system items. This is not possible with the folder browser dialog .

No Lockdown

The folder browser component allows unhindered operations on folders. The user can rename folders, do drag-drop operations and display the context menu and invoke various operations. In many cases, it may be necessary to limit or altogether prevent such potentially dangerous and irreversible operations, however the older browser component provides no way of doing that.

Beyond SHBrowseForFolder : The FolderView Control

The FolderView Control brings a Windows Explorer like folder browser component to your applications complete with AutoUpdate, dragdrop, icons, contextmenus, Non-file system items, default key-handling, infotips and renaming. It features powerful behavior control and customization functionality that takes it miles ahead of Windows Explorer by adding features like filtering, checkboxes, custom items, multiple root nodes, dragdrop control and customization of default contextmenus, displaynames, icons and infotips.

The FolderView control is a UI control which can be dropped right inside your own forms and dialogs. A non-modal file & folder browsing/selection experience right inside your own dialogs and forms is something that users will appreciate and find intuitive and simple.

Additionally, FolderView overcomes all the limitations of SHBrowseForFolder and provides far greater and advanced features and functionality than the SHBrowseForFolder API. The following table is a quick comparison of the FolderView Control with the SHBrowseForFolder.

 

FolderView Control

SHBrowseForFolder

Drop-In Windows Explorer like folder browser functionality. Yes Modal UI. The component cannot be dropped in your own form.
Complete Windows Explorer functionality include a file/folder browsing listview (similar to Windows Explorer's right-side) and a drive selection control (similar to Windows Explorer's address bar) Yes. As part of Shell MegaPack No
Multi-state check boxes Yes No
Filtering capabilities Yes No
Custom controls Yes No
Appearance Control Colors and appearance of the control as a whole and of individual folders/files can be changed. No.
Custom Items Yes No
Prevent renaming, drag-drop, context menus Yes. For all folders or on a per-folder basis. No
Multiple root folders Yes No
Change default display names, icons, overlay icons, infotip, etc Yes No
Simply and easy to use API Yes Clumsy, inflexible API
Access complete information of a file/folder including its displayname, fullpath, checkstate, selection state and attributes like whether it is a shortcut, shared, hidden, readonly, file and folder. Yes No
Prevent display of contextmenus for all folders using a simple property or on a per-folder basis using an event. Yes No
Prevent dragdrop for all folders using a simple property or on a per-folder basis using an event. Yes No
Allow/disallow renaming for all folders using a simple property or on a per-folder basis using an event. Yes No
Allow/disallow selection for all folders using a simple property or on a per-folder basis using an event. Yes No
Allow/disallow expanding/collapsing on a per-folder basis using an event. Yes No
Change default drag actions during dragdrop (e.g. from Copy To Move) Yes No
Control checking/unchecking on a per-folder basis. Yes No
Prevent execution of default shell commands ( e.g. Open, Cut, Properties, etc. in response to keystrokes or through the context menu) for all folders using a simple property or on a per-folder basis using an event. Yes No
Show/hide hidden folders using a simple property. Yes No
Show/hide virtual folders ( e.g. Control Panel ) using a simple property. Yes No
Enumerate all folders shown in FolderView. Yes No
Enumerate all folders according to folder hierarchy structure. Yes No
Execute shell commands ( e.g. Cut, Delete, etc ) on folders. Yes No
Associate developer defined data with each folder Yes No


Controls From Shell MegaPack Being Used in Various IDEs


A Windows Explorer-Like Application Developed Using FolderView And FileView And ShComboBox (Shell MegaPack)

More Info -- Download -- Buy
Have a question? Email us.