--- mstools/samples/mcitest/fileopen.c 2018/08/09 18:22:16 1.1.1.1 +++ mstools/samples/mcitest/fileopen.c 2018/08/09 18:24:32 1.1.1.2 @@ -12,24 +12,23 @@ // global stuff -static char szSearchSpec[_MAX_PATH]; +static TCHAR szSearchSpec[_MAX_PATH]; // routine to invoke the standard file open dialog box -int DlgOpen(HANDLE hModule, HWND hParent, LPSTR lpName, int count) +int DlgOpen(HANDLE hModule, HWND hParent, LPTSTR lpName, int count, UINT flags) { OPENFILENAME ofn; - DWORD flags = OFN_FILEMUSTEXIST; strcpy(szSearchSpec, lpName); - if (strlen(szSearchSpec) == 0) strcpy(szSearchSpec, "*.*"); - dprintf3("Search spec: %s", szSearchSpec); + if (strlen(szSearchSpec) == 0) strcpy(szSearchSpec, TEXT("*.*")); + dprintf3((TEXT("Search spec: %s"), szSearchSpec)); *lpName = 0; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hParent; ofn.hInstance = hModule; - ofn.lpstrFilter = "MCI Files\0*.mci\0All Files\0*.*\0"; + ofn.lpstrFilter = TEXT("MCI Files\0*.mci\0All Files\0*.*\0"); ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; ofn.nFilterIndex = 1; @@ -37,8 +36,7 @@ int DlgOpen(HANDLE hModule, HWND hParent ofn.nMaxFile = count; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; - ofn.lpstrInitialDir = "."; - ofn.lpstrTitle = "File Open"; + ofn.lpstrInitialDir = TEXT(".mci"); ofn.Flags = flags; ofn.nFileOffset = 0; ofn.nFileExtension = 0; @@ -48,12 +46,14 @@ int DlgOpen(HANDLE hModule, HWND hParent ofn.lpTemplateName = NULL; - dprintf3("Calling GetOpenFileName"); - if (GetOpenFileName(&ofn)) { - return(1); + if (flags & OFN_FILEMUSTEXIST) { + ofn.lpstrTitle = TEXT("File Open"); + dprintf3((TEXT("Calling GetOpenFileName"))); + return GetOpenFileName(&ofn); } else { - return(0); - } + ofn.lpstrTitle = TEXT("File Save"); + dprintf3((TEXT("Calling GetSaveFileName"))); + return GetSaveFileName(&ofn); + } } -