Solved

CFileDialog file filters

Posted on 2004-08-03
5
339 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 11

Accepted Solution

by:
KurtVon earned 450 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 50 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.

739 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