// This will tell common file dialog what to show
// and also this will hold its return value
TCHAR sSelectedFile[MAX_PATH_FULL] = {0};
+ String sInitialDir;
// check if specified path is a file
if (initialPath && initialPath[0])
String temp;
paths::SplitFilename(initialPath, 0, &temp, 0);
lstrcpy(sSelectedFile, temp.c_str());
+ sInitialDir = paths::GetParentPath(initialPath);
+ }
+ else
+ {
+ sInitialDir = initialPath;
}
}
ofn.nFilterIndex = 1;
ofn.lpstrFile = sSelectedFile;
ofn.nMaxFile = MAX_PATH_FULL;
- ofn.lpstrInitialDir = initialPath;
+ ofn.lpstrInitialDir = sInitialDir.empty() ? nullptr : sInitialDir.c_str();
ofn.lpstrTitle = title.c_str();
ofn.lpstrFileTitle = nullptr;
if (defaultExtension)