Click here to Skip to main content
13,252,195 members (55,130 online)
Click here to Skip to main content
Add your own
alternative version


12 bookmarked
Posted 23 Sep 2006

Showing Our Template Not Below but Side by Side the CFileDialog Controls

, 23 Sep 2006
Rate this:
Please Sign up or sign in to vote.
Why our template is added at the bottom; here is the way we can add our control side by side other CFileDialog controls
Sample Image - CFileDialogX.jpg


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.

BOOL CFileDialogX::OnInitDialog()
CRect rect;
CWnd * parent = GetParent();
CRect staticWinRect(rect.Width(),,rect.Width()+200-20,rect.Height()-100);
CFont * pfont = parent->GetFont();
mStaticPreview.Create("VC++ shows its 
return TRUE; 

And in 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 CFileDialog.

CFileDialogX mFileOpenDialog(true);


  • 23 Sep 2006: Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

tanvon malik
Pakistan Pakistan
tanvon malik ( real name Tanveer Ahmad )I am a CNC Programmer, cnc setter, cnc operator. want to know about me visit my websites.
CNC Programming
CNC Manuals
DXF & GCode Files with Online Viewers

I been in Switzerland MAG former +FMS+ for CNC training.

Most interesting technologies I like COM MFC DirectShow such as filter development. I am from Pakistan.
Have worked on projects mostly related video capturing, video data processing and real time object tracking on videos. For these I have worked on projects which use "Open CV Library". Which is mostly used for capturing data and its processing.

You may also be interested in...

Comments and Discussions

QuestionWhat a great / simple solution Pin
samjunk26-Sep-06 3:26
membersamjunk26-Sep-06 3:26 
What a great / simple solution. You could change everything about the window using this technique Big Grin | :-D Thanks!
AnswerRe: What a great / simple solution Pin
tanvon malik6-Sep-08 22:39
membertanvon malik6-Sep-08 22:39 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171114.1 | Last Updated 24 Sep 2006
Article Copyright 2006 by tanvon malik
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid