Solved

CFileDialog file filters

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now