Question

I got an error:

error C2664: 'CFileDialog::CFileDialog(BOOL,LPCTSTR,LPCTSTR,DWORD,LPCTSTR,CWnd *,DWORD,BOOL)' : cannot convert parameter 5 from 'const char [52]' to 'LPCTSTR'

in the following code:

CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Movie Files (*.avi;*.mpg;*.mp4)|*.avi;*.mpg;*.mp4||", this);

Please help me. this code worked fine in one project, but when I copy it to other project, it shows the error above.

Was it helpful?

Solution

I expect one project is built as UNICODE and the other is ANSI or MBCS.

Try using the _TEXT() macro, like this:

CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, 
    _T("Movie Files (*.avi;*.mpg;*.mp4)|*.avi;*.mpg;*.mp4||"), this);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top