Everyone who understands VC++ tries at one time to customize the File Open Dialog according to his needs. You can see that there are several such customized dialog boxes on CodeProject too. But I tried to do what nobody has done yet. In this article, I also tried to prove myself.
Why a New Customized CFileOpenDialog
Whenever we try to add a template to this file open dialog, it adds our template at the bottom of the real dialog giving us a second citizen feeling, a bit if not much. Why not prove us as first degree citizens. But how? Here I am going to customize this file open dialog. But I am adding my work side by side the real dialog. This means that now my added control will not show at the bottom, but it will show next to the
listview control of the real file open dialog.
How Is This Done?
I derived a new class from
CFileDialog. In this derived class, I handle the
OnInitDialog() virtual method. This function is called whenever the entire dialog is completed in memory but not yet shown on the screen. So this is the best time to customize this dialog according to my needs. So I add my new control here.
CWnd * parent = GetParent();
CFont * pfont = parent->GetFont();
mStaticPreview.Create("VC++ shows its
OnFileNameChange() notification, I update some stuff about the selected file or folder. But anything can be added there.
Using the Code
It is an easy class
CFileDialogX. You just create an object of it and show the dialog normally as you do
- 23 Sep 2006: Initial version