?
Solved

CFileDialog file filters

Posted on 2004-08-03
5
Medium Priority
?
359 Views
Last Modified: 2013-11-20
Hi,

I wish to create a CFileDialog with a text file and all file filter.  I have tried this but no files are displayed

CFileDialog* dlg = new CFileDialog(FALSE, ".txt", NULL,
  OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
    "Text Files (*.txt) |All Files (*.*)|*.*||", this);

char title[]= { "Create Report" };
dlg->m_ofn.lpstrTitle = title;

if (dlg->DoModal() == IDOK) {


Thanks for any help.
0
Comment
Question by:jasoncpp
  • 3
5 Comments
 
LVL 11

Accepted Solution

by:
KurtVon earned 1800 total points
ID: 11709144
Try "Text Files (*.txt|*.txt|All Files (*.*)|*.*||"

Hope this helps.
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 11709177
Just to clarify, the filter must follow the text description, so right now the "Text Files" description filters so that onlu files that match "All Files (*.*)" are displayed.

Oh, and you don't need the . before the txt for the default filter string.
0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 200 total points
ID: 11709330
There is a little typo in KurtVon's message (missing parenthesis):

"Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"

Also you can simplify this:

char *title =  "Create Report" ;
0
 
LVL 11

Expert Comment

by:KurtVon
ID: 11709431
Erk, sorry.  In my defence, it is a purely cosmetic typo.

And if you want to get technical, it can be simplified further to

dlg->m_ofn.lpstrTitle = "Create Report";
0
 

Author Comment

by:jasoncpp
ID: 11709587
Thank you both, very helpful!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month15 days, 20 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question