Click here to Skip to main content
15,889,595 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Small Help. Pin
shultas7-Jan-04 2:56
shultas7-Jan-04 2:56 
GeneralRe: Small Help. Pin
Prakash Nadar7-Jan-04 6:55
Prakash Nadar7-Jan-04 6:55 
GeneralRe: Small Help. Pin
shultas7-Jan-04 11:16
shultas7-Jan-04 11:16 
GeneralSetActiveView Pin
skylonely6-Jan-04 20:29
skylonely6-Jan-04 20:29 
GeneralRe: SetActiveView Pin
morefalt6-Jan-04 23:32
morefalt6-Jan-04 23:32 
GeneralCFileDialog - Open Dialog Pin
murali_utr6-Jan-04 20:21
murali_utr6-Jan-04 20:21 
GeneralRe: CFileDialog - Open Dialog Pin
BaldwinMartin6-Jan-04 21:08
BaldwinMartin6-Jan-04 21:08 
GeneralRe: CFileDialog - Open Dialog Pin
shultas7-Jan-04 2:14
shultas7-Jan-04 2:14 
Hello. I am somewhat a beginner myself therefore I don't know enough to go into "complete detail". If you are trying to do a normal file selection dialog box, you don't really need to use OFN_ENABLETEMPLATE. I'm pasting some code for you below. Notice one thing from your original post. You have CStrExt in the wrong place. The second parameter to construct this dialog is:

lpszDefExt

The default filename extension. If the user does not include an extension in the Filename edit box, the extension specified by lpszDefExt is automatically appended to the filename. If this parameter is NULL, no file extension is appended.

That's just a default extension. Say the dialog box pops up, and there's a file in there called "test.txt". If the default filename extension was set to ".txt" and I typed in "test" to the dialog box, it would automatically append ".txt" to the end of it allowing me to quickly select the file without having to type in "test.txt".

So, your CStrExt should actually go in the 5th place, which is:

lpszFilter

A series of string pairs that specify filters you can apply to the file. If you specify file filters, only selected files will appear in the Files list box. See the Remarks section for more information on how to work with file filters.

Give that a try. That shall present a dialog box and work for you. I am not really sure (as I said I am a beginner myself) how the templates work, but I'm pretty sure that's where your problem is in there. You are trying to use a template and there is something not right in there so when you try to construct the dialog box, the program cannot find the template handle that you are trying to use, and therefore never brings up the box.

This code here will work for you:


CString CStrExt;
CStrExt = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"; // a more appropriate name
// would be CStrFilter

//Either of the following work. The first one with the ",0" at the end will make a nicer looking
// dialog box that has my computer, etc on the left hand side. The second one makes
// a normal "older style" dialog box. (for WXP)

// CFileDialog SelDialog(TRUE, NULL, NULL, OFN_HIDEREADONLY,CStrExt,this,0);
CFileDialog SelDialog(TRUE, NULL, NULL, OFN_HIDEREADONLY,CStrExt,this);


if(SelDialog.DoModal() == IDOK)
{
MessageBox(SelDialog.GetPathName());
}

Hope that helps you out.
GeneralThanks Pin
murali_utr7-Jan-04 16:04
murali_utr7-Jan-04 16:04 
GeneralCompiling problem.. Pin
KellyR6-Jan-04 17:55
KellyR6-Jan-04 17:55 
GeneralRe: Compiling problem.. Pin
KellyR6-Jan-04 18:01
KellyR6-Jan-04 18:01 
GeneralCListCtrl and Printing Pin
Sitaram Sukumar6-Jan-04 17:37
Sitaram Sukumar6-Jan-04 17:37 
GeneralRe: CListCtrl and Printing Pin
sunil samineni6-Jan-04 18:53
sunil samineni6-Jan-04 18:53 
GeneralRe: CListCtrl and Printing Pin
Selvam R6-Jan-04 19:13
professionalSelvam R6-Jan-04 19:13 
Generala question about createprocess Pin
cchere6-Jan-04 17:36
cchere6-Jan-04 17:36 
GeneralRe: a question about createprocess Pin
Selvam R6-Jan-04 19:19
professionalSelvam R6-Jan-04 19:19 
GeneralRe: a question about createprocess Pin
Anonymous7-Jan-04 6:19
Anonymous7-Jan-04 6:19 
GeneralRe: a question about createprocess Pin
David Crow7-Jan-04 6:44
David Crow7-Jan-04 6:44 
GeneralRe: a question about createprocess Pin
cchere7-Jan-04 9:41
cchere7-Jan-04 9:41 
GeneralRe: a question about createprocess Pin
David Crow7-Jan-04 9:45
David Crow7-Jan-04 9:45 
GeneralRe: a question about createprocess Pin
cchere7-Jan-04 10:36
cchere7-Jan-04 10:36 
GeneralRe: a question about createprocess Pin
David Crow7-Jan-04 2:54
David Crow7-Jan-04 2:54 
GeneralRe: a question about createprocess Pin
Anonymous7-Jan-04 6:10
Anonymous7-Jan-04 6:10 
GeneralPrinting Bitmaps Pin
GESY6-Jan-04 15:44
GESY6-Jan-04 15:44 
GeneralCan't import my dll functions Pin
benwestgarth6-Jan-04 15:33
benwestgarth6-Jan-04 15:33 

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.