Click here to Skip to main content
Click here to Skip to main content

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

Introduction

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()
{
CFileDialog::OnInitDialog();
CRect rect;
CWnd * parent = GetParent();
parent->GetWindowRect(&rect);
parent->SetWindowPos(0,rect.left,rect.top,rect.Width()+200,rect.Height(),0);
ScreenToClient(rect);
CRect staticWinRect(rect.Width(),rect.top+65,rect.Width()+200-20,rect.Height()-100);
CFont * pfont = parent->GetFont();
mStaticPreview.Create("VC++ shows its 
mystries",WS_CHILD|WS_VISIBLE|WS_BORDER,staticWinRect,parent);
mStaticPreview.SetFont(pfont,false);
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);
mFileOpenDialog.DoModal(); 

History

  • 23 Sep 2006: Initial version

License

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 blog.
CNC Programming Blog
 
Reach Me
cnc blog | facebook | twitter | linkedin | flickr | google+
 
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.
 
my vc++ blog tanvon++
my blog about DirectShow in my national language URDU DirectShow.wordpress.com
and below is the place where we discuss DirectShow and VC++
http://groups.yahoo.com/group/tanvon
Follow on   Twitter

Comments and Discussions

 
QuestionWhat a great / simple solution Pinmembersamjunk26-Sep-06 2:26 
AnswerRe: What a great / simple solution Pinmembertanvon malik6-Sep-08 21:39 

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 24 Sep 2006
Article Copyright 2006 by tanvon malik
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid