Solved

CFileDialog question

Posted on 1998-11-20
5
233 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
Comment Utility
Override the OnTypeChange notification, and upate the file name there
0
 

Author Comment

by:roar
Comment Utility
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
Comment Utility
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
Comment Utility
Adjusted points to 200
0
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 200 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

771 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

10 Experts available now in Live!

Get 1:1 Help Now