This is my second article on the topic Customizing "Browse for folder" dialog and in the previous article (Customizing the "Browse for folder" dialog Part - I) we have seen how to add the caption and the edit box on the browse for folder dialog.
In the previous code we have seen how to add simple controls on the dialog but, some people have problem to add the custom controls like a "Check Box","Button" and interfacing with them and that's why I a writing the special article to interface with these controls and adding them on the dialog box.
I think the code given below is very simple to understand if you are familiar with the WIN32API. The code subclasses the controls and then we can interface them through our program. The code uses simple functions like
SendWindowLong to subclass the dialog control. Once the control has been subclassed then every thing is yours. You can process the messages as usual and then you can process the messages as regular.
Creating the controls
To create the controls I have used the
CreateWindowEx function but here, for the check box the class is "BUTTON" and flag is the
BS_AUTOCHECKBOX that will create the check box. The code is as given below...
edit=CreateWindowEx(0,"EDIT","Yogesh M Joshi.",WS_CHILD|WS_VISIBLE|WS_BORDER|
checkbox = CreateWindowEx(0,"BUTTON","Show the edit control.",
Here edit and the checkbox give the handles to the respective control.
Subclassing the control
The subclassing of the control is the very important thing since we are interfacing with the controls. Actually, we don't have the main dialog procedure of the browse for folder dialog, and so, I am subclassing the check box within the
BFFM_INITIALIZED message. this gives us the better way because the controls are just being created. Here the
WNDPROC declares the default window procedure which have to be returned named
CBProc. This will go in the following way.
CBProc = (WNDPROC) SetWindowLong(checkbox,GWL_WNDPROC,
CheckBoxSubClassProc is the subclass procedure which will process the messages. As sown below...
LRESULT APIENTRY CheckBoxSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,
return CallWindowProc(CBProc, hwnd, uMsg,
Processing the messages :
To process the messages posted by the main window procedure of the Browse for folder dialog, we have declared the procedure above. and the just put the following code to that procedure. (I have used the
LBUTTONUP message I don't get the result of CLICK message). Here
ShowWindow function will set the visibility of the edit control by
In this way we can add and subclass the controls on the browse for folder dialog. I thing You will get the "WINAMP" styled browse for folder dialog with this code try for it. That's not over wait for the Part - III of this article. click the following links to contact me or visit my website for COOL programs. Mail me at : email@example.com. Visit my website : http://www.stechome.netfirms.com/