Search code examples
mfcdirectorywindows-2000

MFC CFileDialog don't work correctly in Windows 2000


I develop with Visual Studio 2008 (Windows 7) and use

CFileDialog(TRUE, NULL, lastPath, NULL, szFilter);

The important parameter is the third (lastPath) to get in a specific directory! All works fine with Windows 7 but in Windows 2000 the Dialog only works if lastPath (LPCTSTR lpszFileName) is empty (otherwise the Dialog doesn't open)

Any ideas!?

Thanks and greets leon22


Solution

  • Ok, I have found the error:

    don't set the initial directory with lpszFileName!

    Right usage:

    CFileDialog oDlg(TRUE, NULL, NULL, NULL, szFilter);
    oDlg.m_ofn.lpstrInitialDir = lastPath.GetBuffer(0); // set initial dir
    

    greets leon22