Click here to Skip to main content
15,617,328 members
Articles / Desktop Programming / MFC
Posted 20 Apr 2003


30 bookmarked

Customizing the "Browse for folder" dialog

Rate me:
Please Sign up or sign in to vote.
3.47/5 (12 votes)
20 Apr 20032 min read
This Program customizes the "Browse For folder dialog" with a few lines of code...

Sample Image - Customize_FolderDialog_1.jpg


I was just working with WIN32 apis and I thought that when we use the browse for folder dialog boxes, at that time there is nothing that shows us the full path and so, I have written this program.

How It Works?

This code is fully based on the win32 apis. I am giving this functionality using the basic functions; let us discuss them one by one...


This program uses the simple win32 api function calls like , FindWindowEx, CreateWindow etc. With these functions we can create the edit box and the static control. The CreateWindowEx function is used to create the child controls that are one edit box and the one static control. Then just add it to the Browse for folder dialog.


Firstly Declare the lpofn to the BorwseCallbackProc Procedure. Then the whenever the browse for folder dialog box initializes that time it will send the message to the procedure that is "BFFM_INITIALIZED". That time create the edit and the static controls like below...

//Create the edit and static control on the dialog box
edit=CreateWindowEx(0,"EDIT","Yogesh M Joshi.",WS_CHILD|WS_VISIBLE|WS_BORDER|
HWND caption=CreateWindowEx(0,"STATIC","You have selected the folder :",

Here the ghInstance is the instance of the dialog box. The "EDIT" and "STATIC" are the names of the classes. and The flags sets the style of the contols. Just then we will have to resize the list view contol but firstly we will find it on the "Browse For Folder" dialog, That's so easy just use the FindWindowEx function.

HWND ListView=FindWindowEx(hwnd,NULL,"SysTreeView32",NULL);

In this way we have find the handle of the List iew then resize it. Use the GetWindowRect function to get the rectangles of the "Browse For Folder" Dialog. This will take place in the following way...

//Gets the dimentions of the windows

//Sets the listview controls dimentions
            ( )-20,290,170,0);
//Sets the window positions of edit and dialog controls
            ( )+170,290,20,SWP_SHOWWINDOW);
            ( )+152,290,16,SWP_SHOWWINDOW);

And then I have used the SetFont function to set the fonts of the static and edit control.

//This will set the font of the controls
void SetFont(HWND hwnd,LPTSTR FontName,int FontSize)
    HFONT hf;
    LOGFONT lf={0};
    HDC hdc=GetDC(hwnd);
    lf.lfWeight = FW_REGULAR;
    lf.lfHeight = (LONG)FontSize;
    lstrcpy( lf.lfFaceName, FontName );

In this way we have resized the contols. But main thing is not over that if we select any folder then the edit contol must show it. For this purpose the callback message "BFFM_SELCHANGED" and use the SetWindowText api to set the text of the edit contol.

//Selection change message
    t = SHGetPathFromIDList((ITEMIDLIST*)lParam, c);

    //Sets the text of the edit control to the current folder

That's all and in this way we can customize the "Browse For Folder" dialog box.


Use this code for educational purpose only. Mail your comments at : and to pick some COOL windows utilities isit my homepage at I am waiting to hear from you.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Written By
Software Developer AVAYA India Pvt Ltd.
India India
I have completed my B.E. Degree in IT form Aditya Engineering College, Beed. (Maharashtra) India.

I have completed Diploma In Advanced Computing (DAC) in Feb 07.

Now I am working for AVAYA India Pvt. LTD as software engineer.
Platform : C/C++, Solaris 10, AIX and Windows

Comments and Discussions

QuestionNew Folder Pin
iWizardPro25-Nov-09 7:30
iWizardPro25-Nov-09 7:30 
QuestionCan We Use this Control in ASP.NET For Web Application Pin
sunilp30-Jan-09 7:16
sunilp30-Jan-09 7:16 
rawbite11-Nov-06 22:32
rawbite11-Nov-06 22:32 
GeneralPassing the folder path Pin
Joel++16-Apr-05 19:16
Joel++16-Apr-05 19:16 
GeneralRe: Passing the folder path Pin
Anonymous18-Apr-05 7:04
Anonymous18-Apr-05 7:04 
GeneralRe: Passing the folder path Pin
Yogesh M Joshi18-Apr-05 7:12
Yogesh M Joshi18-Apr-05 7:12 
Your question is intresting! you may do these things by two ways
1. Subclass the edit window or
2. At the end dialog message you may change the variable c by getting the string value from the edit box.

in this way the returning buffer will have the path of your typed folder!;P
GeneralRe: Passing the folder path Pin
Joel++1-May-05 4:54
Joel++1-May-05 4:54 
GeneralAdding a checkbox Pin
Mav Rossi22-Apr-03 7:46
Mav Rossi22-Apr-03 7:46 
GeneralRe: Adding a checkbox Pin
Mav Rossi22-Apr-03 8:13
Mav Rossi22-Apr-03 8:13 
GeneralRe: Adding a checkbox Pin
Yogesh M Joshi24-Apr-03 22:56
Yogesh M Joshi24-Apr-03 22:56 
GeneralTo generate Drive Control Pin
Lalit Kandi10-Jul-06 21:51
Lalit Kandi10-Jul-06 21:51 
GeneralFeature already supported Pin
Ernest Laurentin21-Apr-03 4:09
Ernest Laurentin21-Apr-03 4:09 
GeneralRe: Feature already supported Pin
Yogesh M Joshi21-Apr-03 4:49
Yogesh M Joshi21-Apr-03 4:49 
GeneralNice idea and a suggestion Pin
Jerry Evans21-Apr-03 3:20
Jerry Evans21-Apr-03 3:20 
GeneralRe: Nice idea and a suggestion Pin
Yogesh M Joshi21-Apr-03 4:54
Yogesh M Joshi21-Apr-03 4:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.