Index: src/winhugs/DlgMain.c =================================================================== RCS file: /cvs/hugs98/src/winhugs/DlgMain.c,v retrieving revision 1.11 diff -u -r1.11 DlgMain.c --- src/winhugs/DlgMain.c 14 Sep 2005 10:15:35 -0000 1.11 +++ src/winhugs/DlgMain.c 7 Oct 2005 11:23:27 -0000 @@ -217,25 +217,9 @@ { CHAR FileName[MAX_PATH]; CHAR Command[2048]; - OPENFILENAME ofn; - FileName[0] = 0; - - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hInstance = hThisInstance; - ofn.hwndOwner = hWnd; - ofn.lpstrFilter = "Haskell Files (*.hs;*.lhs)\0*.hs;*.lhs\0All Files (*.*)\0*.*\0"; - ofn.nFilterIndex = 1; - ofn.lpstrFile= FileName; - ofn.nMaxFile = MAX_PATH; - ofn.lpstrFileTitle = NULL; - ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER; - ofn.lpfnHook = NULL; - ofn.lpstrInitialDir = NULL; - - if (!GetOpenFileName(&ofn)) - return; + if (!ShowOpenFileDialog(hWnd, FileName)) + return; wsprintf(Command, ":load %s\n", ExpandFileName((String)FileName)); FireCommand(Command); Index: src/winhugs/General.c =================================================================== RCS file: /cvs/hugs98/src/winhugs/General.c,v retrieving revision 1.2 diff -u -r1.2 General.c --- src/winhugs/General.c 4 Oct 2005 15:26:38 -0000 1.2 +++ src/winhugs/General.c 7 Oct 2005 11:23:05 -0000 @@ -172,3 +172,24 @@ } return Expanded; } + +BOOL ShowOpenFileDialog(HWND hParent, LPSTR FileName) +{ + OPENFILENAME ofn; + + FileName[0] = 0; + memset(&ofn, 0, sizeof(ofn)); + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hInstance = hThisInstance; + ofn.hwndOwner = hParent; + ofn.lpstrFilter = "Haskell Files (*.hs;*.lhs)\0*.hs;*.lhs\0All Files (*.*)\0*.*\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFile= FileName; + ofn.nMaxFile = MAX_PATH; + ofn.lpstrFileTitle = NULL; + ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER; + ofn.lpfnHook = NULL; + ofn.lpstrInitialDir = NULL; + + return GetOpenFileName(&ofn); +} \ No newline at end of file Index: src/winhugs/Header.h =================================================================== RCS file: /cvs/hugs98/src/winhugs/Header.h,v retrieving revision 1.5 diff -u -r1.5 Header.h --- src/winhugs/Header.h 16 Sep 2005 16:51:25 -0000 1.5 +++ src/winhugs/Header.h 7 Oct 2005 11:23:13 -0000 @@ -16,6 +16,8 @@ void ExecuteFile(LPSTR FileName); void CenterDialogInParent(HWND hDlg); void ExecuteFileDocs(LPSTR FileName); +BOOL ShowOpenFileDialog(HWND hParent, LPSTR FileName); + // Exported from Registry.c void RegistryReadFont(CHARFORMAT* cf); Index: src/winhugs/Legacy.c =================================================================== RCS file: /cvs/hugs98/src/winhugs/Legacy.c,v retrieving revision 1.4 diff -u -r1.4 Legacy.c --- src/winhugs/Legacy.c 8 Sep 2005 16:04:41 -0000 1.4 +++ src/winhugs/Legacy.c 7 Oct 2005 11:26:21 -0000 @@ -2359,85 +2359,6 @@ smUpto++; } -/* Used to get a file name using a common dialog box. Returns a pointer to */ -/* a static string where the file name is, or NULL if cancel button is pushed */ -/* Mask is the identificator of a string defined in Hugs.Rc where the type */ -/* of files and their masks are */ -static CHAR *local GetaFileName(HWND hWnd, UINT Mask) -{ -#define MAXEXTENSIONS 15 - - static CHAR Extensions[MAXEXTENSIONS][_MAX_EXT + 1]; - static OPENFILENAME ofn; - static CHAR szFileName[_MAX_PATH]; - CHAR szFile[_MAX_PATH], szFileTitle[_MAX_PATH]; - UINT i, j, cbString, n; - CHAR chReplace; /* Separator between different filters in szFilter */ - CHAR szFilter[300]; - char currentDir[_MAX_PATH]; - - szFile[0] = '\0'; - - if ((cbString = LoadString(hThisInstance, Mask, - szFilter, sizeof(szFilter))) == 0) { - /* Error */ - return NULL; - } - chReplace = szFilter[cbString - 1]; /* Get separator */ - - /* Get valid extensions for files */ - for (n = 0, i = 0; szFilter[i];) { - while (szFilter[i] != chReplace) - i++; - i++; - do { - while (szFilter[i] != '.') - i++; - i++; - j = 0; - while ((szFilter[i] != ';') - && (szFilter[i] != chReplace)) { - Extensions[n][j++] = szFilter[i++]; - } - Extensions[n++][j] = (CHAR) 0; - } while (szFilter[i] == ';'); - i++; - } - for (; n < MAXEXTENSIONS; n++) - Extensions[n][0] = (CHAR) 0; - - /* Replace separator with NULL */ - for (i = 0; szFilter[i] != '\0'; i++) { - if (szFilter[i] == chReplace) - szFilter[i] = '\0'; - } - - memset(&ofn, 0, sizeof(OPENFILENAME)); - - ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hInstance = hThisInstance; - ofn.hwndOwner = hWnd; - ofn.lpstrFilter = szFilter; - ofn.nFilterIndex = 1; - ofn.lpstrFile = szFile; - ofn.nMaxFile = sizeof(szFile); - ofn.lpstrFileTitle = szFileTitle; - ofn.nMaxFileTitle = sizeof(szFileTitle); - ofn.Flags = - OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | - OFN_EXPLORER;; - ofn.lpfnHook = NULL; - GetCurrentDirectory(_MAX_PATH, currentDir); - ofn.lpstrInitialDir = currentDir; - - if (GetOpenFileName(&ofn)) { - strcpy(szFileName, ofn.lpstrFile); - return szFileName; - } else { - return NULL; - } -} - INT_PTR CALLBACK ScriptManDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -2504,11 +2425,10 @@ "Add script", MB_ICONEXCLAMATION | MB_OK); else { - String s = - GetaFileName(hDlg, IDS_FILTERFILE); - if (s) - SmAddScr(hDlg, s); - } + CHAR Buffer[MAX_PATH]; + if (ShowOpenFileDialog(hDlg, Buffer)) + SmAddScr(hDlg, Buffer); + } return TRUE; case ID_DELSCRIPT: