CFileDialog OnTypeChange and file already exists dialog  
Author Message
satpp





PostPosted: Visual C++ General, CFileDialog OnTypeChange and file already exists dialog Top

I derived a class from CFileDialog and overrode the OnTypeChange() function in order to automatically change or append the new extension when the user changes the type dropdown similar to dialog in office. That part is working as expected.
My problem is that when the user enters a filename with an invalid extension and clicks save, the correct extension is appended but it performs the file already exists check on the original filename and would not prompt the user.

For example:
1. Book1.xml.zip exists in the directory.
2. The .zip type is already selected in the file dialog.
3. The user types Book1.xml into the filename and clicks save.
The filename is changed to Book1.xml.zip and returned as the filename but the user is never prompted to overwrite the file.

If I swap steps 2 and 3 so that the filename says Book1.xml.zip before saving then it would perform the check and display the prompt. If Book1.xml exists, then the user would be prompted to overwrite Book1.xml. I change the type in the OnFileNameOK() function before the base version but it seems to be too late.

Is there a way to call the default check or change the filename earlier like capturing the save button event

Thanks.


Visual C++11  
 
 
Bite Qiu - MSFT





PostPosted: Visual C++ General, CFileDialog OnTypeChange and file already exists dialog Top

Hello

Re: CFileDialog OnTypeChange and file already exists dialog

Such questions are outside the scope of this forum - for the scope of the Visual C++ General forum please look at: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=19445&SiteID=1

The more appropriate place for your question is probably the MFC newsgroup: http://msdn.microsoft.com/newsgroups/default.aspx dg=microsoft.public.vc.mfc&lang=en&cr=US

OTP

Thanks

Bite