I'm giving a user a CFileDialog to save their work. One of the file types supported is CSV, but within CSV there are a couple variations (e.g., row-major, column-major, etc.). I know I can add controls to the dialog to allow such a choice but given that there's already an output file type selector I'd like to use that if possible.
CFileDialog multiple CSV file types
394 views Asked by Swiss Frank At
1
I am going to assume that you know how to add mutiple file types to the
CFileDialoglist as there are lots of articles about that.Once the window has been dismissed you can consider using the GetOFN method. This returns a OPENFILENAME structure.
If you look closely at the information for this structure you will see:
So, once the window is dismissed you can get the selected filter index value. Since you know what type of CSV file is associated with each index you know what to do.
Update
You can also initialize the
CFileDialogbefore it is displayed by modifying the same structure. For example:You can set the filters etc. directly using this method and then display the window. Then afterwards, access the structure to get the selected index at the moment the window was dismissed.