Solved

CFileDialog file filters

Posted on 2004-08-03
5
329 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 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Creating Labels and Frequency list style reports in SAS code 9 98
sum28 challenge 31 112
firstChar challenge 13 115
Sed question 2 86
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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 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