Author: akhaldi
Date: Fri Aug 19 09:24:04 2016
New Revision: 72338

URL: http://svn.reactos.org/svn/reactos?rev=72338&view=rev
Log:
[COMDLG32] Sync with Wine Staging 1.9.16. CORE-11866

Modified:
    trunk/reactos/dll/win32/comdlg32/colordlg.c
    trunk/reactos/dll/win32/comdlg32/filedlg.c
    trunk/reactos/dll/win32/comdlg32/itemdlg.c
    trunk/reactos/dll/win32/comdlg32/printdlg.c
    trunk/reactos/media/doc/README.WINE

Modified: trunk/reactos/dll/win32/comdlg32/colordlg.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comdlg32/colordlg.c?rev=72338&r1=72337&r2=72338&view=diff
==============================================================================
--- trunk/reactos/dll/win32/comdlg32/colordlg.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/comdlg32/colordlg.c [iso-8859-1] Fri Aug 19 
09:24:04 2016
@@ -235,7 +235,7 @@
   /* draw it */
   hdc = GetDC(hwnd);
   DrawFocusRect(hdc, &rect);
-  CopyRect(&lpp->focusRect, &rect);
+  lpp->focusRect = rect;
   lpp->hwndFocus = hwnd;
   ReleaseDC(hwnd, hdc);
 }

Modified: trunk/reactos/dll/win32/comdlg32/filedlg.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comdlg32/filedlg.c?rev=72338&r1=72337&r2=72338&view=diff
==============================================================================
--- trunk/reactos/dll/win32/comdlg32/filedlg.c  [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/comdlg32/filedlg.c  [iso-8859-1] Fri Aug 19 
09:24:04 2016
@@ -196,6 +196,7 @@
 static LPITEMIDLIST GetPidlFromName(IShellFolder *psf,LPWSTR lpcstrFileName);
 static BOOL IsPidlFolder (LPSHELLFOLDER psf, LPCITEMIDLIST pidl);
 static UINT GetNumSelected( IDataObject *doSelected );
+static void COMCTL32_ReleaseStgMedium(STGMEDIUM medium);
 
 /* Shell memory allocation */
 static void *MemAlloc(UINT size);
@@ -3588,6 +3589,25 @@
 }
 
 /***********************************************************************
+ *          get_def_format
+ *
+ * Fill the FORMATETC used in the shell id list
+ */
+static FORMATETC get_def_format(void)
+{
+    static CLIPFORMAT cfFormat;
+    FORMATETC formatetc;
+
+    if (!cfFormat) cfFormat = RegisterClipboardFormatA(CFSTR_SHELLIDLISTA);
+    formatetc.cfFormat = cfFormat;
+    formatetc.ptd = 0;
+    formatetc.dwAspect = DVASPECT_CONTENT;
+    formatetc.lindex = -1;
+    formatetc.tymed = TYMED_HGLOBAL;
+    return formatetc;
+}
+
+/***********************************************************************
  * FILEDLG95_FILENAME_FillFromSelection
  *
  * fills the edit box from the cached DataObject
@@ -3596,84 +3616,72 @@
 {
     FileOpenDlgInfos *fodInfos;
     LPITEMIDLIST      pidl;
-    UINT              nFiles = 0, nFileToOpen, nFileSelected, nLength = 0;
-    WCHAR             lpstrTemp[MAX_PATH];
-    LPWSTR            lpstrAllFile, lpstrCurrFile;
+    LPWSTR            lpstrAllFiles, lpstrTmp;
+    UINT nFiles = 0, nFileToOpen, nFileSelected, nAllFilesLength = 0, 
nThisFileLength, nAllFilesMaxLength;
+    STGMEDIUM medium;
+    LPIDA cida;
+    FORMATETC formatetc = get_def_format();
 
     TRACE("\n");
     fodInfos = GetPropA(hwnd,FileOpenDlgInfosStr);
 
-    /* Count how many files we have */
-    nFileSelected = GetNumSelected( fodInfos->Shell.FOIDataObject );
-
-    /* calculate the string length, count files */
-    if (nFileSelected >= 1)
-    {
-      nLength += 3;    /* first and last quotes, trailing \0 */
-      for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
-      {
-        pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, 
nFileToOpen+1 );
-
+    if (FAILED(IDataObject_GetData(fodInfos->Shell.FOIDataObject, &formatetc, 
&medium)))
+        return;
+
+    cida = GlobalLock(medium.u.hGlobal);
+    nFileSelected = cida->cidl;
+
+    /* Allocate a buffer */
+    nAllFilesMaxLength = MAX_PATH + 3;
+    lpstrAllFiles = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 
nAllFilesMaxLength * sizeof(WCHAR));
+    if (!lpstrAllFiles)
+        goto ret;
+
+    /* Loop through the selection, handle only files (not folders) */
+    for (nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++)
+    {
+        pidl = (LPITEMIDLIST)((LPBYTE)cida + cida->aoffset[nFileToOpen + 1]);
         if (pidl)
-       {
-          /* get the total length of the selected file names */
-          lpstrTemp[0] = '\0';
-          GetName( fodInfos->Shell.FOIShellFolder, pidl, 
SHGDN_INFOLDER|SHGDN_FORPARSING, lpstrTemp );
-
-          if ( ! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl) ) /* 
Ignore folders */
-         {
-            nLength += lstrlenW( lpstrTemp ) + 3;
-            nFiles++;
-         }
-          COMDLG32_SHFree( pidl );
-       }
-      }
-    }
-
-    /* allocate the buffer */
-    if (nFiles <= 1) nLength = MAX_PATH;
-    lpstrAllFile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, nLength * 
sizeof(WCHAR));
-
-    /* Generate the string for the edit control */
-    if(nFiles >= 1)
-    {
-      lpstrCurrFile = lpstrAllFile;
-      for ( nFileToOpen = 0; nFileToOpen < nFileSelected; nFileToOpen++ )
-      {
-        pidl = GetPidlFromDataObject( fodInfos->Shell.FOIDataObject, 
nFileToOpen+1 );
-
-        if (pidl)
-       {
-         /* get the file name */
-          lpstrTemp[0] = '\0';
-          GetName( fodInfos->Shell.FOIShellFolder, pidl, 
SHGDN_INFOLDER|SHGDN_FORPARSING, lpstrTemp );
-
-          if (! IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl)) /* Ignore 
folders */
-         {
-            if ( nFiles > 1)
-           {
-              *lpstrCurrFile++ =  '\"';
-              lstrcpyW( lpstrCurrFile, lpstrTemp );
-              lpstrCurrFile += lstrlenW( lpstrTemp );
-              *lpstrCurrFile++ = '\"';
-              *lpstrCurrFile++ = ' ';
-              *lpstrCurrFile = 0;
-           }
-           else
-           {
-              lstrcpyW( lpstrAllFile, lpstrTemp );
-           }
-          }
-          COMDLG32_SHFree( pidl );
-       }
-      }
-      SetWindowTextW( fodInfos->DlgInfos.hwndFileName, lpstrAllFile );
-       
-      /* Select the file name like Windows does */
-      if (filename_is_edit( fodInfos ))
-          SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1);
-    }
-    HeapFree(GetProcessHeap(),0, lpstrAllFile );
+        {
+            if (!IsPidlFolder(fodInfos->Shell.FOIShellFolder, pidl))
+            {
+                if (nAllFilesLength + MAX_PATH + 3 > nAllFilesMaxLength)
+                {
+                    nAllFilesMaxLength *= 2;
+                    lpstrTmp = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 
lpstrAllFiles, nAllFilesMaxLength * sizeof(WCHAR));
+                    if (!lpstrTmp)
+                        goto ret;
+                    lpstrAllFiles = lpstrTmp;
+                }
+                nFiles += 1;
+                lpstrAllFiles[nAllFilesLength++] = '"';
+                GetName(fodInfos->Shell.FOIShellFolder, pidl, SHGDN_INFOLDER | 
SHGDN_FORPARSING, lpstrAllFiles + nAllFilesLength);
+                nThisFileLength = lstrlenW(lpstrAllFiles + nAllFilesLength);
+                nAllFilesLength += nThisFileLength;
+                lpstrAllFiles[nAllFilesLength++] = '"';
+                lpstrAllFiles[nAllFilesLength++] = ' ';
+            }
+        }
+    }
+
+    if (nFiles != 0)
+    {
+        /* If there's only one file, use the name as-is without quotes */
+        lpstrTmp = lpstrAllFiles;
+        if (nFiles == 1)
+        {
+            lpstrTmp += 1;
+            lpstrTmp[nThisFileLength] = 0;
+        }
+        SetWindowTextW(fodInfos->DlgInfos.hwndFileName, lpstrTmp);
+        /* Select the file name like Windows does */
+        if (filename_is_edit(fodInfos))
+            SendMessageW(fodInfos->DlgInfos.hwndFileName, EM_SETSEL, 0, -1);
+    }
+
+ret:
+    HeapFree(GetProcessHeap(), 0, lpstrAllFiles);
+    COMCTL32_ReleaseStgMedium(medium);
 }
 
 
@@ -3733,15 +3741,6 @@
        MemFree(lpstrEdit);
        return nFileCount;
 }
-
-#define SETDefFormatEtc(fe,cf,med) \
-{ \
-    (fe).cfFormat = cf;\
-    (fe).dwAspect = DVASPECT_CONTENT; \
-    (fe).ptd =NULL;\
-    (fe).tymed = med;\
-    (fe).lindex = -1;\
-};
 
 /*
  * DATAOBJECT Helper functions
@@ -3776,16 +3775,13 @@
 {
 
     STGMEDIUM medium;
-    FORMATETC formatetc;
+    FORMATETC formatetc = get_def_format();
     LPITEMIDLIST pidl = NULL;
 
     TRACE("sv=%p index=%u\n", doSelected, nPidlIndex);
 
     if (!doSelected)
         return NULL;
-       
-    /* Set the FORMATETC structure*/
-    SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLISTA), 
TYMED_HGLOBAL);
 
     /* Get the pidls from IDataObject */
     if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))
@@ -3810,14 +3806,11 @@
 {
     UINT retVal = 0;
     STGMEDIUM medium;
-    FORMATETC formatetc;
+    FORMATETC formatetc = get_def_format();
 
     TRACE("sv=%p\n", doSelected);
 
     if (!doSelected) return 0;
-
-    /* Set the FORMATETC structure*/
-    SETDefFormatEtc(formatetc, RegisterClipboardFormatA(CFSTR_SHELLIDLISTA), 
TYMED_HGLOBAL);
 
     /* Get the pidls from IDataObject */
     if(SUCCEEDED(IDataObject_GetData(doSelected,&formatetc,&medium)))

Modified: trunk/reactos/dll/win32/comdlg32/itemdlg.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comdlg32/itemdlg.c?rev=72338&r1=72337&r2=72338&view=diff
==============================================================================
--- trunk/reactos/dll/win32/comdlg32/itemdlg.c  [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/comdlg32/itemdlg.c  [iso-8859-1] Fri Aug 19 
09:24:04 2016
@@ -386,14 +386,12 @@
 
 static BOOL set_file_name(FileDialogImpl *This, LPCWSTR str)
 {
-    HWND hwnd_edit = GetDlgItem(This->dlg_hwnd, IDC_FILENAME);
-
     if(This->set_filename)
         LocalFree(This->set_filename);
 
-    This->set_filename = StrDupW(str);
-
-    return SendMessageW(hwnd_edit, WM_SETTEXT, 0, (LPARAM)str);
+    This->set_filename = str ? StrDupW(str) : NULL;
+
+    return SetDlgItemTextW(This->dlg_hwnd, IDC_FILENAME, This->set_filename);
 }
 
 static void fill_filename_from_selection(FileDialogImpl *This)
@@ -2610,10 +2608,8 @@
         return E_INVALIDARG;
 
     *pszName = NULL;
-    if(get_file_name(This, pszName))
-        return S_OK;
-    else
-        return E_FAIL;
+    get_file_name(This, pszName);
+    return *pszName ? S_OK : E_FAIL;
 }
 
 static HRESULT WINAPI IFileDialog2_fnSetTitle(IFileDialog2 *iface, LPCWSTR 
pszTitle)

Modified: trunk/reactos/dll/win32/comdlg32/printdlg.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comdlg32/printdlg.c?rev=72338&r1=72337&r2=72338&view=diff
==============================================================================
--- trunk/reactos/dll/win32/comdlg32/printdlg.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/comdlg32/printdlg.c [iso-8859-1] Fri Aug 19 
09:24:04 2016
@@ -3595,11 +3595,8 @@
         default_page_paint_hook(hWnd, WM_PSD_MARGINRECT, (WPARAM)hdc, 
(LPARAM)&rcMargin, data);
 
         /* give text a bit of a space from the frame */
-        rcMargin.left += 2;
-        rcMargin.top += 2;
-        rcMargin.right -= 2;
-        rcMargin.bottom -= 2;
-        
+        InflateRect(&rcMargin, -2, -2);
+
         /* if the space is too small then we make sure to not draw anything */
         rcMargin.left = min(rcMargin.left, rcMargin.right);
         rcMargin.top = min(rcMargin.top, rcMargin.bottom);

Modified: trunk/reactos/media/doc/README.WINE
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=72338&r1=72337&r2=72338&view=diff
==============================================================================
--- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original)
+++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Fri Aug 19 09:24:04 2016
@@ -55,7 +55,7 @@
 reactos/dll/win32/clusapi             # Synced to WineStaging-1.9.11
 reactos/dll/win32/comcat              # Synced to WineStaging-1.9.11
 reactos/dll/win32/comctl32            # Synced to WineStaging-1.9.16
-reactos/dll/win32/comdlg32            # Synced to WineStaging-1.9.11
+reactos/dll/win32/comdlg32            # Synced to WineStaging-1.9.16
 reactos/dll/win32/compstui            # Synced to WineStaging-1.9.11
 reactos/dll/win32/credui              # Synced to WineStaging-1.9.16
 reactos/dll/win32/crypt32             # Synced to WineStaging-1.9.16


Reply via email to