patch untested - comdlg32 split more filedlg work

Steven Edwards Steven_Ed4153 at yahoo.com
Thu Jun 19 10:25:59 CDT 2003


You were right Alexandre,
All of this just to remove one call to CallWindowProc16. There has got 
to be a better way to do this as we are going to end up with a lot of 
duplicated code for Win16 support. This thing needs a total rewrite.

Changelog:
More splitting of the Win16/32 internal filedlgproc Window Procedures 
and Dialog Init.
Make a few internal function static and share a few others.


-------------- next part --------------
Index: filedlg.h
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/filedlg.h,v
retrieving revision 1.1
diff -u -r1.1 filedlg.h
--- filedlg.h	16 Jun 2003 01:19:16 -0000	1.1
+++ filedlg.h	19 Jun 2003 15:11:40 -0000
@@ -58,10 +58,9 @@
  * Do not Export to other applications or dlls
  */
 
-BOOL FILEDLG_CallWindowProc(LFSPRIVATE lfs, UINT wMsg, WPARAM wParam,
-                                   LPARAM lParam);
-LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam);
+LPWSTR FILEDLG_GetFileType(LPWSTR cfptr, LPWSTR fptr, WORD index);
 void FILEDLG_MapDrawItemStruct(LPDRAWITEMSTRUCT16 lpdis16, LPDRAWITEMSTRUCT lpdis);
+BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath);
 LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
        int savedlg, LPDRAWITEMSTRUCT lpdis);
 LRESULT FILEDLG_WMCommand(HWND hWnd, LPARAM lParam, UINT notification,

*****CVS exited normally with code 1*****

cvs diff -u filedlg.c 
Index: filedlg.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/filedlg.c,v
retrieving revision 1.63
diff -u -r1.63 filedlg.c
--- filedlg.c	16 Jun 2003 01:19:16 -0000	1.63
+++ filedlg.c	19 Jun 2003 15:11:49 -0000
@@ -257,15 +257,9 @@
  *
  *      Call the appropriate hook
  */
-BOOL FILEDLG_CallWindowProc(LFSPRIVATE lfs, UINT wMsg, WPARAM wParam,
+static BOOL FILEDLG_CallWindowProc(LFSPRIVATE lfs, UINT wMsg, WPARAM wParam,
                                    LPARAM lParam)
 {
-    if (lfs->ofn16)
-    {
-        return (BOOL16) CallWindowProc16(
-          (WNDPROC16)lfs->ofn16->lpfnHook, HWND_16(lfs->hwnd),
-          (UINT16)wMsg, (WPARAM16)wParam, lParam);
-    }
     if (lfs->ofnA)
     {
         return (BOOL) CallWindowProcA(
@@ -286,7 +280,7 @@
 /***********************************************************************
  * 				FILEDLG_ScanDir                 [internal]
  */
-static BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath)
+BOOL FILEDLG_ScanDir(HWND hWnd, LPWSTR newPath)
 {
     WCHAR		buffer[BUFFILE];
     HWND 		hdlg, hdlgDir;
@@ -338,7 +332,7 @@
  * 				FILEDLG_GetFileType		[internal]
  */
 
-static LPWSTR FILEDLG_GetFileType(LPWSTR cfptr, LPWSTR fptr, WORD index)
+LPWSTR FILEDLG_GetFileType(LPWSTR cfptr, LPWSTR fptr, WORD index)
 {
   int n, i;
   i = 0;
@@ -482,7 +476,7 @@
  *                              FILEDLG_WMInitDialog            [internal]
  */
 
-LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
+static LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
 {
   int i, n;
   WCHAR tmpstr[BUFFILE];

Index: filedlg16.c
===================================================================
RCS file: /home/wine/wine/dlls/commdlg/filedlg16.c,v
retrieving revision 1.1
diff -u -r1.1 filedlg16.c
--- filedlg16.c	16 Jun 2003 01:19:16 -0000	1.1
+++ filedlg16.c	19 Jun 2003 15:11:57 -0000
@@ -40,6 +40,139 @@
 #include "filedlg.h"
 
 /***********************************************************************
+ *                              FILEDLG_CallWindowProc16          [internal]
+ *
+ *      Call the appropriate hook
+ */
+static BOOL FILEDLG_CallWindowProc16(LFSPRIVATE lfs, UINT wMsg, WPARAM wParam,
+                                   LPARAM lParam)
+{
+    if (lfs->ofn16)
+    {
+        return (BOOL16) CallWindowProc16(
+          (WNDPROC16)lfs->ofn16->lpfnHook, HWND_16(lfs->hwnd),
+          (UINT16)wMsg, (WPARAM16)wParam, lParam);
+    }
+    return FALSE;
+}
+
+/***********************************************************************
+ *                              FILEDLG_WMInitDialog16            [internal]
+ *      The is a duplicate of the 32bit FILEDLG_WMInitDialog function 
+ *      The only differnce is that it calls FILEDLG_CallWindowProc16 
+ *      for a 16 bit Window Proc.
+ */
+
+static LONG FILEDLG_WMInitDialog16(HWND hWnd, WPARAM wParam, LPARAM lParam)
+{
+  int i, n;
+  WCHAR tmpstr[BUFFILE];
+  LPWSTR pstr, old_pstr;
+  LPOPENFILENAMEW ofn;
+  LFSPRIVATE lfs = (LFSPRIVATE) lParam;
+
+  if (!lfs) return FALSE;
+  SetPropA(hWnd, OFN_PROP, (HANDLE)lfs);
+  lfs->hwnd = hWnd;
+  ofn = lfs->ofnW;
+
+  TRACE("flags=%lx initialdir=%s\n", ofn->Flags, debugstr_w(ofn->lpstrInitialDir));
+
+  SetWindowTextW( hWnd, ofn->lpstrTitle );
+  /* read custom filter information */
+  if (ofn->lpstrCustomFilter)
+    {
+      pstr = ofn->lpstrCustomFilter;
+      n = 0;
+      TRACE("lpstrCustomFilter = %p\n", pstr);
+      while(*pstr)
+	{
+	  old_pstr = pstr;
+          i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
+                                   (LPARAM)(ofn->lpstrCustomFilter) + n );
+          n += lstrlenW(pstr) + 1;
+	  pstr += lstrlenW(pstr) + 1;
+	  TRACE("add str=%s associated to %s\n",
+                debugstr_w(old_pstr), debugstr_w(pstr));
+          SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
+          n += lstrlenW(pstr) + 1;
+	  pstr += lstrlenW(pstr) + 1;
+	}
+    }
+  /* read filter information */
+  if (ofn->lpstrFilter) {
+	pstr = (LPWSTR) ofn->lpstrFilter;
+	n = 0;
+	while(*pstr) {
+	  old_pstr = pstr;
+	  i = SendDlgItemMessageW(hWnd, cmb1, CB_ADDSTRING, 0,
+				       (LPARAM)(ofn->lpstrFilter + n) );
+	  n += lstrlenW(pstr) + 1;
+	  pstr += lstrlenW(pstr) + 1;
+	  TRACE("add str=%s associated to %s\n",
+                debugstr_w(old_pstr), debugstr_w(pstr));
+	  SendDlgItemMessageW(hWnd, cmb1, CB_SETITEMDATA, i, (LPARAM)pstr);
+	  n += lstrlenW(pstr) + 1;
+	  pstr += lstrlenW(pstr) + 1;
+	}
+  }
+  /* set default filter */
+  if (ofn->nFilterIndex == 0 && ofn->lpstrCustomFilter == NULL)
+  	ofn->nFilterIndex = 1;
+  SendDlgItemMessageW(hWnd, cmb1, CB_SETCURSEL, ofn->nFilterIndex - 1, 0);
+  lstrcpynW(tmpstr, FILEDLG_GetFileType(ofn->lpstrCustomFilter,
+	     (LPWSTR)ofn->lpstrFilter, ofn->nFilterIndex - 1),BUFFILE);
+  TRACE("nFilterIndex = %ld, SetText of edt1 to %s\n",
+  			ofn->nFilterIndex, debugstr_w(tmpstr));
+  SetDlgItemTextW( hWnd, edt1, tmpstr );
+  /* get drive list */
+  *tmpstr = 0;
+  DlgDirListComboBoxW(hWnd, tmpstr, cmb2, 0, DDL_DRIVES | DDL_EXCLUSIVE);
+  /* read initial directory */
+  /* FIXME: Note that this is now very version-specific (See MSDN description of
+   * the OPENFILENAME structure).  For example under 2000/XP any path in the
+   * lpstrFile overrides the lpstrInitialDir, but not under 95/98/ME
+   */
+  if (ofn->lpstrInitialDir != NULL)
+    {
+      int len;
+      lstrcpynW(tmpstr, ofn->lpstrInitialDir, 511);
+      len = lstrlenW(tmpstr);
+      if (len > 0 && tmpstr[len-1] != '\\'  && tmpstr[len-1] != ':') {
+        tmpstr[len]='\\';
+        tmpstr[len+1]='\0';
+      }
+    }
+  else
+    *tmpstr = 0;
+  if (!FILEDLG_ScanDir(hWnd, tmpstr)) {
+    *tmpstr = 0;
+    if (!FILEDLG_ScanDir(hWnd, tmpstr))
+      WARN("Couldn't read initial directory %s!\n", debugstr_w(tmpstr));
+  }
+  /* select current drive in combo 2, omit missing drives */
+  {
+      char dir[MAX_PATH];
+      char str[4] = "a:\\";
+      GetCurrentDirectoryA( sizeof(dir), dir );
+      for(i = 0, n = -1; i < 26; i++)
+      {
+          str[0] = 'a' + i;
+          if (GetDriveTypeA(str) > DRIVE_NO_ROOT_DIR) n++;
+          if (toupper(str[0]) == toupper(dir[0])) break;
+      }
+  }
+  SendDlgItemMessageW(hWnd, cmb2, CB_SETCURSEL, n, 0);
+  if (!(ofn->Flags & OFN_SHOWHELP))
+    ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
+  if (ofn->Flags & OFN_HIDEREADONLY)
+    ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
+  if (lfs->hook)
+      return (BOOL) FILEDLG_CallWindowProc16(lfs, WM_INITDIALOG, wParam, lfs->lParam);
+  return TRUE;
+}
+
+/***********************************************************************
  *                              FILEDLG_WMMeasureItem16         [internal]
  */
 static LONG FILEDLG_WMMeasureItem16(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
@@ -66,14 +199,14 @@
     TRACE("msg=%x wparam=%x lParam=%lx\n", wMsg, wParam, lParam);
     if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
         {
-            LRESULT lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
+            LRESULT lRet = (BOOL16)FILEDLG_CallWindowProc16(lfs, wMsg, wParam, lParam);
             if (lRet)
                 return lRet;         /* else continue message processing */
         }
     switch (wMsg)
     {
     case WM_INITDIALOG:
-        return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
+        return FILEDLG_WMInitDialog16(hWnd, wParam, lParam);
 
     case WM_MEASUREITEM:
         return FILEDLG_WMMeasureItem16(hWnd16, wParam, lParam);
@@ -116,13 +249,13 @@
  if ((wMsg != WM_INITDIALOG) && lfs && lfs->hook)
   {
    LRESULT  lRet;
-   lRet = (BOOL16)FILEDLG_CallWindowProc(lfs, wMsg, wParam, lParam);
+   lRet = (BOOL16)FILEDLG_CallWindowProc16(lfs, wMsg, wParam, lParam);
    if (lRet)
     return lRet;         /* else continue message processing */
   }
   switch (wMsg) {
    case WM_INITDIALOG:
-      return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
+      return FILEDLG_WMInitDialog16(hWnd, wParam, lParam);
 
    case WM_MEASUREITEM:
       return FILEDLG_WMMeasureItem16(hWnd16, wParam, lParam);


More information about the wine-patches mailing list