PATCH: GetFileDialog95A/W (comdlg32)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Changelog:
- save and restore current directory in GetFileDialog95W if OFN_NOCHANGEDIR flag set
- GetFileDialog95W: only convert ofn->lpTemplateName if it's a string resource id
   (fixes OpenOffice 1.0 file open dialog crash)
- Ignore OFN_FILEMUSTEXIST flag for save file dialog
   (fixes save dialog in ElstarFormular)
- Rewrote casts that some compilers don't accept

Author: Sander van Leeuwen (sandervl@xs4all.nl)

--- filedlg95.c	Fri Jun  7 08:13:40 2002
+++ filedlg95.cn	Sun Jun  9 13:26:56 2002
@@ -330,6 +330,7 @@
       break;
     case SAVE_DIALOG :
       fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
+      ofn->Flags &= ~OFN_FILEMUSTEXIST;
       ret = GetFileName95(fodInfos);
       break;
     default :
@@ -403,6 +404,7 @@
   BOOL ret;
   FileOpenDlgInfos *fodInfos;
   HINSTANCE hInstance;
+  LPSTR lpstrSavDir = NULL;
 
   /* out arguments */
   LPWSTR lpstrFile = NULL;
@@ -444,7 +446,7 @@
     len = WideCharToMultiByte( CP_ACP, 0, ofn->lpstrFilter, n, NULL, 0, NULL, NULL );
     y = (LPSTR)MemAlloc(len);
     WideCharToMultiByte( CP_ACP, 0, ofn->lpstrFilter, n, y, len, NULL, NULL );
-    (LPSTR)ofn->lpstrFilter = y;
+    ofn->lpstrFilter = (LPWSTR)y;
   }
 
   /* convert lpstrCustomFilter */
@@ -463,7 +465,7 @@
     len = WideCharToMultiByte( CP_ACP, 0, ofn->lpstrCustomFilter, n, NULL, 0, NULL, NULL );
     y = (LPSTR)MemAlloc(len);
     WideCharToMultiByte( CP_ACP, 0, ofn->lpstrCustomFilter, n, y, len, NULL, NULL );
-    (LPSTR)ofn->lpstrCustomFilter = y;
+    ofn->lpstrCustomFilter = (LPWSTR)y;
   }
 
   /* convert string arguments, save others */
@@ -472,10 +474,21 @@
   AllocInArgWtoA(ofn->lpstrInitialDir, lpstrInitialDir);
   AllocInArgWtoA(ofn->lpstrTitle, lpstrTitle);
   AllocInArgWtoA(ofn->lpstrDefExt, lpstrDefExt);
-  AllocInArgWtoA(ofn->lpTemplateName, lpTemplateName);
+  if(HIWORD(ofn->lpTemplateName)) {
+       AllocInArgWtoA(ofn->lpTemplateName, lpTemplateName);
+  }
+  else lpTemplateName = ofn->lpTemplateName;
+
   dwFlags = ofn->Flags;
   hInstance = ofn->hInstance;
 
+  /* save current directory */
+  if (ofn->Flags & OFN_NOCHANGEDIR)
+  {
+     lpstrSavDir = MemAlloc(MAX_PATH);
+     GetCurrentDirectoryA(MAX_PATH, lpstrSavDir);
+  }
+
   ofn->Flags = ofn->Flags|OFN_WINE|OFN_UNICODE;
   ofn->hInstance = MapHModuleLS(ofn->hInstance);
 
@@ -486,12 +499,19 @@
       break;
   case SAVE_DIALOG :
       fodInfos->DlgInfos.dwDlgProp |= FODPROP_SAVEDLG;
+      ofn->Flags &= ~OFN_FILEMUSTEXIST;
       ret = GetFileName95(fodInfos);
       break;
   default :
       ret = 0;
   }
 
+  if (lpstrSavDir)
+  {
+      SetCurrentDirectoryA(lpstrSavDir);
+      MemFree(lpstrSavDir);
+  }
+
   /* restore saved IN arguments and convert OUT arguments back */
   ofn->Flags = dwFlags;
   ofn->hInstance = hInstance;
@@ -502,8 +522,10 @@
   FreeInArg(ofn->lpstrInitialDir, lpstrInitialDir);
   FreeInArg(ofn->lpstrTitle, lpstrTitle);
   FreeInArg(ofn->lpstrDefExt, lpstrDefExt);
-  FreeInArg(ofn->lpTemplateName, lpTemplateName);
-
+  if(HIWORD(lpTemplateName)) {
+       FreeInArg(ofn->lpTemplateName, lpTemplateName);
+  }
+  else ofn->lpTemplateName = lpTemplateName;
   MemFree((LPVOID)(fodInfos));
   return ret;
 }




[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux