[PATCH 3/3] comdlg32.dll - Make 3.1-style OpenFileName() function display dir tree Added #defines for SETITEMDATA indent storage

Dirk Niggemann dirk.niggemann at gmail.com
Mon Feb 24 16:49:58 CST 2020


Signed-off-by: Dirk Niggemann <dirk.niggemann at gmail.com>
---
 dlls/comdlg32/filedlg31.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/dlls/comdlg32/filedlg31.c b/dlls/comdlg32/filedlg31.c
index 43dbf7f9af..0d9293421a 100644
--- a/dlls/comdlg32/filedlg31.c
+++ b/dlls/comdlg32/filedlg31.c
@@ -43,6 +43,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
 #define BUFFILE 512
 #define BUFFILEALLOC 512 * sizeof(WCHAR)
 
+#define FLAG_FLDR_OPEN 0x10000
+#define INDENT_MASK 0xffff
+
 static const WCHAR FILE_star[] = {'*','.','*', 0};
 static const WCHAR FILE_bslash[] = {'\\', 0};
 static const WCHAR FILE_specc[] = {'%','c',':', 0};
@@ -206,9 +209,8 @@ static LRESULT FD31_Directory( HWND hdlg, LPCWSTR filespec, int pos, int indent,
                 else
                     lstrcpyW( buffer , entry.cFileName );
                 if (!long_names) CharLowerW( buffer );
-                /* pos = LISTBOX_FindFileStrPos( descr, buffer ); */
                 SendMessageW(hdlg, LB_INSERTSTRING, pos+n, (LPARAM)buffer);
-                SendMessageW(hdlg, LB_SETITEMDATA, pos+n, curropen == (pos+n) ? indent | 0x10000 : indent);
+                SendMessageW(hdlg, LB_SETITEMDATA, pos+n, curropen == (pos+n) ? indent | FLAG_FLDR_OPEN : indent);
                 if (ret <= maxinsert) maxinsert++; else maxinsert = ret;
                 n++;
             }
@@ -267,7 +269,7 @@ static BOOL FD31_ScanDir(const OPENFILENAMEW *ofn, HWND hWnd, LPCWSTR newPath,
         WCHAR * sepptr;
         UINT n = 0;
         WCHAR pathcomp[BUFFILE];
-	SendMessageW(hdlg, LB_RESETCONTENT, 0, 0);
+        SendMessageW(hdlg, LB_RESETCONTENT, 0, 0);
         while (dir)
         {
            sepptr = wcschr(dir, FILE_bslash[0]);
@@ -285,9 +287,9 @@ static BOOL FD31_ScanDir(const OPENFILENAMEW *ofn, HWND hWnd, LPCWSTR newPath,
 	   dir = (sepptr) ? (sepptr + 1) : 0;
            /* last entry sets open folder if -1 */
            if (curropen == -1 && !dir)
-	      SendMessageW(hdlg, LB_SETITEMDATA, n, n | 0x10000 );
+	      SendMessageW(hdlg, LB_SETITEMDATA, n, n | FLAG_FLDR_OPEN );
            else
-	      SendMessageW(hdlg, LB_SETITEMDATA, n,n == curropen ? n | 0x10000 : n);
+	      SendMessageW(hdlg, LB_SETITEMDATA, n,n == curropen ? n | FLAG_FLDR_OPEN : n);
            n++;
         }
         FD31_Directory(hdlg, buffer, n, n, curropen, TRUE);
@@ -307,9 +309,9 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
     COLORREF oldText = 0, oldBk = 0;
     ULONG indent = 0;
 
-    if (lpdis->itemData) 
+    if (lpdis->itemData)
     {
-        indent = lpdis->itemData & 0xffff;
+        indent = lpdis->itemData & INDENT_MASK;
     }
     if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
     {
@@ -365,7 +367,7 @@ static LONG FD31_WMDrawItem(HWND hWnd, WPARAM wParam, LPARAM lParam,
 	    SetBkColor( lpdis->hDC, oldBk );
 	    SetTextColor( lpdis->hDC, oldText );
 	}
-        if (lpdis->itemData & 0x10000)
+        if (lpdis->itemData & FLAG_FLDR_OPEN)
 	    DrawIconEx( lpdis->hDC, lpdis->rcItem.left + indent*indentWidth, lpdis->rcItem.top, hFolder2, 16, 16, 0, 0, DI_NORMAL );
         else
 	    DrawIconEx( lpdis->hDC, lpdis->rcItem.left + indent*indentWidth, lpdis->rcItem.top, hFolder, 16, 16, 0, 0, DI_NORMAL );
@@ -508,7 +510,7 @@ static LRESULT FD31_DirListDblClick( FD31_DATA *lfs )
   if (lRet == LB_ERR) return TRUE;
   pstr = heap_alloc(BUFFILEALLOC);
   SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, lRet, (LPARAM)pstr);
-  currindent = SendDlgItemMessageW(hWnd, lst2, LB_GETITEMDATA, lRet, 0) & 0xffff;
+  currindent = SendDlgItemMessageW(hWnd, lst2, LB_GETITEMDATA, lRet, 0) & INDENT_MASK;
   lfs->curropen = currindent;
   lstrcpyW( tmpstr, pstr );
   /* get the selected directory in tmpstr */
@@ -521,7 +523,7 @@ static LRESULT FD31_DirListDblClick( FD31_DATA *lfs )
   while (n >= 0)
   {
      SendDlgItemMessageW(hWnd, lst2, LB_GETTEXT, n, (LPARAM)pstr);
-     indent = SendDlgItemMessageW(hWnd, lst2, LB_GETITEMDATA, n, 0) & 0xffff;
+     indent = SendDlgItemMessageW(hWnd, lst2, LB_GETITEMDATA, n, 0) & INDENT_MASK;
      if (indent < currindent)
      {
        lstrcpyW(tmpstr2, pstr);
@@ -1178,7 +1180,7 @@ static LONG FD31_WMInitDialog(HWND hWnd, WPARAM wParam, LPARAM lParam)
   if (ofn->Flags & OFN_HIDEREADONLY)
     ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
   if (lfs->hook)
-     return FD31_CallWindowProc(lfs, WM_INITDIALOG, wParam, lfs->lParam);
+      return FD31_CallWindowProc(lfs, WM_INITDIALOG, wParam, lfs->lParam);
   return TRUE;
 }
 
-- 
2.17.2 (Apple Git-113)




More information about the wine-devel mailing list