문제

I am using CFileDialog for displaying the open file dialog. I have set the filter as follows:

static TCHAR BASED_CODE szFilter[] = _T("Chart Files (*.xlc)|*.xlc|")
                                     _T("Worksheet Files (*.xls)|*.xls|Data Files (*.xlc;*.xls)|")
                                     _T("*.xlc; *.xls|All Files (*.*)|*.*||");

I need to set the default file type to be "Worksheet Files" whenever I DoModal the dialog box. I am unable to figure out how to do it. MS Paint is doing, it selects the "All Picture files" when we open the open file dialog.

Please let me know how to do it.

도움이 되었습니까?

해결책

You're looking for the SetDefExt function. This allows you to specify the default file extension for an open/save file dialog box. Remember that the string you specify should not contain a period (.).

Of course, you could also just specify this in the constructor. The second parameter is the default extension (lpszDefExt).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top