CFileDialog question

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?
roarAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Tommy HuiConnect With a Mentor EngineerCommented:
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
 
MikeP090797Commented:
Override the OnTypeChange notification, and upate the file name there
0
 
roarAuthor Commented:
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
 
roarAuthor Commented:
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
 
roarAuthor Commented:
Adjusted points to 200
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.