• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 242
  • Last Modified:

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?
0
roar
Asked:
roar
  • 3
1 Solution
 
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
 
Tommy HuiEngineerCommented:
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

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now