?
Solved

CFileDialog file filters

Posted on 2004-08-03
5
Medium Priority
?
348 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 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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

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 …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

765 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