Solved

CFileDialog question

Posted on 1998-11-20
5
234 Views
Last Modified: 2013-11-20
In a "save as" CFileDialog the user can choose between two file types. I want the extension of the file name to to be updated when user selects another file type.
How do I do that?
0
Comment
Question by:roar
  • 3
5 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1325029
Override the OnTypeChange notification, and upate the file name there
0
 

Author Comment

by:roar
ID: 1325030
Isn't it possible to make CFileDialog do it automatically?
This is a very common, so I would expect that CFileDialog could do that.

0
 

Author Comment

by:roar
ID: 1325031
If I add a OnTypeChange notification, I can update the filename in m_ofn.lpstrFile.
But the filename isn't updated in the dialog, how do I do that?
0
 

Author Comment

by:roar
ID: 1325032
Adjusted points to 200
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 200 total points
ID: 1325033
Since CFileDialog is derived from CDialog, you can use any of the methods of CDialog on a CFileDialog. The most important one is GetDlgItem(). You need to retrieve the CWnd* pointer of the edit control. In this case, the id of the edit control you want is edt1. You'll need to include <dlgs.h>

  CWnd* edt = cfd.GetDlgItem(edt1);
  if (edt)
  {
    edt->SetWindowText(newFileName);
  }
  cfd.m_ofn.lpstrFile = newFileName;

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

911 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

26 Experts available now in Live!

Get 1:1 Help Now