--- np2/win9x/dialog/dialogs.cpp 2005/03/20 13:12:50 1.8 +++ np2/win9x/dialog/dialogs.cpp 2007/07/20 14:39:12 1.10 @@ -1,6 +1,7 @@ #include "compiler.h" #include "strres.h" #include "bmpdata.h" +#include "oemtext.h" #include "dosio.h" #include "commng.h" #include "dialogs.h" @@ -8,6 +9,8 @@ #include "mt32snd.h" #endif +extern HINSTANCE hInst; + const TCHAR str_nc[] = _T("N/C"); @@ -24,52 +27,92 @@ const TCHAR str_int6[] = _T("INT6"); BOOL dlgs_selectfile(HWND hWnd, const FILESEL *item, OEMCHAR *path, UINT size, int *ro) { + TCHAR *pszTitle; OPENFILENAME ofn; +#if defined(OSLANG_UTF8) + TCHAR _path[MAX_PATH]; +#endif + BOOL bResult; if ((item == NULL) || (path == NULL) || (size == 0)) { return(FALSE); } + pszTitle = lockstringresource(hInst, item->title); + ZeroMemory(&ofn, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWnd; ofn.lpstrFilter = item->filter; ofn.nFilterIndex = item->defindex; +#if defined(OSLANG_UTF8) + oemtotchar(_path, NELEMENTS(_path), path, -1); + ofn.lpstrFile = _path; + ofn.nMaxFile = NELEMENTS(_path); +#else ofn.lpstrFile = path; ofn.nMaxFile = size; +#endif ofn.Flags = OFN_FILEMUSTEXIST; ofn.lpstrDefExt = item->ext; - ofn.lpstrTitle = item->title; - if (!GetOpenFileName(&ofn)) { - return(FALSE); - } - if (ro) { - *ro = ofn.Flags & OFN_READONLY; + ofn.lpstrTitle = pszTitle; + + bResult = GetOpenFileName(&ofn); + unlockstringresource(pszTitle); + + if (bResult) { +#if defined(OSLANG_UTF8) + tchartooem(path, NELEMENTS(path), _path, -1); +#endif + if (ro) { + *ro = ofn.Flags & OFN_READONLY; + } } - return(TRUE); + return(bResult); } BOOL dlgs_selectwritefile(HWND hWnd, const FILESEL *item, OEMCHAR *path, UINT size) { OPENFILENAME ofn; + TCHAR *pszTitle; +#if defined(OSLANG_UTF8) + TCHAR _path[MAX_PATH]; +#endif + BOOL bResult; if ((item == NULL) || (path == NULL) || (size == 0)) { return(FALSE); } + + pszTitle = lockstringresource(hInst, item->title); + ZeroMemory(&ofn, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWnd; ofn.lpstrFilter = item->filter; ofn.nFilterIndex = item->defindex; +#if defined(OSLANG_UTF8) + oemtotchar(_path, NELEMENTS(_path), path, -1); + ofn.lpstrFile = _path; + ofn.nMaxFile = NELEMENTS(_path); +#else ofn.lpstrFile = path; ofn.nMaxFile = size; +#endif ofn.Flags = OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; ofn.lpstrDefExt = item->ext; - ofn.lpstrTitle = item->title; - if (!GetSaveFileName(&ofn)) { - return(FALSE); + ofn.lpstrTitle = pszTitle; + + bResult = GetSaveFileName(&ofn); + + unlockstringresource(pszTitle); + +#if defined(OSLANG_UTF8) + if (bResult) { + tchartooem(path, NELEMENTS(path), _path, -1); } - return(TRUE); +#endif + return(bResult); } BOOL dlgs_selectwritenum(HWND hWnd, const FILESEL *item,