Author: akhaldi
Date: Sun Mar  5 20:57:05 2017
New Revision: 74092

URL: http://svn.reactos.org/svn/reactos?rev=74092&view=rev
Log:
[COMDLG32] Sync with Wine Staging 2.2. CORE-12823

e07d20f comdlg32: Don't crash if an IShellFolder could not be created.
bd1b3c1 comdlg32: Use localized "Path does not exist" string.
1707df3 comdlg32: Delay OleInitialize() until after file dialog window is 
created.
6c4aaf7 comdlg32: Always use original Open File dialog template.
eff2ecc comdlg32: Avoid some superfluous pointer casts.

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

Modified: trunk/reactos/dll/win32/comdlg32/filedlg.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comdlg32/filedlg.c?rev=74092&r1=74091&r2=74092&view=diff
==============================================================================
--- trunk/reactos/dll/win32/comdlg32/filedlg.c  [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/comdlg32/filedlg.c  [iso-8859-1] Sun Mar  5 
20:57:05 2017
@@ -219,14 +219,10 @@
  */
 static BOOL GetFileName95(FileOpenDlgInfos *fodInfos)
 {
-
     LRESULT lRes;
-    LPCVOID origTemplate;
-    DWORD dwSize;
-    LPDLGTEMPLATEW template;
+    void *template;
     HRSRC hRes;
     HANDLE hDlgTmpl = 0;
-    HRESULT hr;
 
     /* test for missing functionality */
     if (fodInfos->ofnInfos->Flags & UNIMPLEMENTED_FLAGS)
@@ -242,36 +238,25 @@
         COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
         return FALSE;
     }
-    if (!(dwSize = SizeofResource(COMDLG32_hInstance, hRes)) ||
-        !(hDlgTmpl = LoadResource(COMDLG32_hInstance, hRes)) ||
-        !(origTemplate = LockResource(hDlgTmpl)))
+    if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hRes )) ||
+        !(template = LockResource( hDlgTmpl )))
     {
         COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
         return FALSE;
     }
-    if (!(template = HeapAlloc(GetProcessHeap(), 0, dwSize)))
-    {
-        COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
-        return FALSE;
-    }
-    memcpy(template, origTemplate, dwSize);
 
     /* msdn: explorer style dialogs permit sizing by default.
      * The OFN_ENABLESIZING flag is only needed when a hook or
-     * custom tmeplate is provided */
+     * custom template is provided */
     if( (fodInfos->ofnInfos->Flags & OFN_EXPLORER) &&
             !(fodInfos->ofnInfos->Flags & ( OFN_ENABLEHOOK | 
OFN_ENABLETEMPLATE | OFN_ENABLETEMPLATEHANDLE)))
         fodInfos->ofnInfos->Flags |= OFN_ENABLESIZING;
 
     if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
     {
-        template->style |= WS_SIZEBOX;
         fodInfos->sizedlg.cx = fodInfos->sizedlg.cy = 0;
         fodInfos->initial_size.x = fodInfos->initial_size.y = 0;
     }
-    else
-        template->style &= ~WS_SIZEBOX;
-
 
     /* old style hook messages */
     if (IsHooked(fodInfos))
@@ -281,9 +266,6 @@
       fodInfos->HookMsg.helpmsgstring = RegisterWindowMessageW(HELPMSGSTRINGW);
       fodInfos->HookMsg.sharevistring = RegisterWindowMessageW(SHAREVISTRINGW);
     }
-
-    /* Some shell namespace extensions depend on COM being initialized. */
-    hr = OleInitialize(NULL);
 
     if (fodInfos->unicode)
       lRes = DialogBoxIndirectParamW(COMDLG32_hInstance,
@@ -297,10 +279,8 @@
                                      fodInfos->ofnInfos->hwndOwner,
                                      FileOpenDlgProc95,
                                      (LPARAM) fodInfos);
-    if (SUCCEEDED(hr)) 
+    if (fodInfos->ole_initialized)
         OleUninitialize();
-
-    HeapFree(GetProcessHeap(), 0, template);
 
     /* Unable to create the dialog */
     if( lRes == -1)
@@ -1263,7 +1243,11 @@
          int gripx = GetSystemMetrics( SM_CYHSCROLL);
          int gripy = GetSystemMetrics( SM_CYVSCROLL);
 
-        /* Adds the FileOpenDlgInfos in the property list of the dialog
+         /* Some shell namespace extensions depend on COM being initialized. */
+         if (SUCCEEDED(OleInitialize(NULL)))
+             fodInfos->ole_initialized = TRUE;
+
+         /* Adds the FileOpenDlgInfos in the property list of the dialog
             so it will be easily accessible through a GetPropA(...) */
          SetPropA(hwnd, FileOpenDlgInfosStr, fodInfos);
 
@@ -1271,7 +1255,31 @@
 
          if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
          {
-             GetWindowRect( hwnd, &rc);
+             DWORD style = GetWindowLongW(hwnd, GWL_STYLE);
+             DWORD ex_style = GetWindowLongW(hwnd, GWL_EXSTYLE);
+             RECT client, client_adjusted;
+
+             if (fodInfos->ofnInfos->Flags & OFN_ENABLESIZING)
+             {
+                 style |= WS_SIZEBOX;
+                 ex_style |= WS_EX_WINDOWEDGE;
+             }
+             else
+                 style &= ~WS_SIZEBOX;
+             SetWindowLongW(hwnd, GWL_STYLE, style);
+             SetWindowLongW(hwnd, GWL_EXSTYLE, ex_style);
+
+             GetClientRect( hwnd, &client );
+             GetClientRect( hwnd, &client_adjusted );
+             AdjustWindowRectEx( &client_adjusted, style, FALSE, ex_style );
+
+             GetWindowRect( hwnd, &rc );
+             rc.right += client_adjusted.right - client.right;
+             rc.bottom += client_adjusted.bottom - client.bottom;
+             SetWindowPos(hwnd, 0, 0, 0, rc.right - rc.left, rc.bottom - 
rc.top, SWP_FRAMECHANGED | SWP_NOACTIVATE |
+                 SWP_NOZORDER | SWP_NOMOVE);
+
+             GetWindowRect( hwnd, &rc );
              fodInfos->DlgInfos.hwndGrip =
                  CreateWindowExA( 0, "SCROLLBAR", NULL,
                      WS_CHILD | WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS |
@@ -2911,7 +2919,8 @@
       IShellView_DestroyViewWindow(fodInfos->Shell.FOIShellView);
       IShellView_Release(fodInfos->Shell.FOIShellView);
     }
-    IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
+    if (fodInfos->Shell.FOIShellFolder)
+      IShellFolder_Release(fodInfos->Shell.FOIShellFolder);
     IShellBrowser_Release(fodInfos->Shell.FOIShellBrowser);
     if (fodInfos->Shell.FOIDataObject)
       IDataObject_Release(fodInfos->Shell.FOIDataObject);
@@ -3987,9 +3996,9 @@
           if ( FAILED( IShellBrowser_BrowseObject( 
fodInfos->Shell.FOIShellBrowser,
                          pidlSelection, SBSP_RELATIVE ) ) )
           {
-               static const WCHAR notexist[] = {'P','a','t','h',' 
','d','o','e','s',
-                                   ' ','n','o','t',' ','e','x','i','s','t',0};
-               MessageBoxW( hwnd, notexist, fodInfos->title, MB_OK | 
MB_ICONEXCLAMATION );
+               WCHAR buf[64];
+               LoadStringW( COMDLG32_hInstance, IDS_PATHNOTEXISTING, buf, 
sizeof(buf)/sizeof(WCHAR) );
+               MessageBoxW( hwnd, buf, fodInfos->title, MB_OK | 
MB_ICONEXCLAMATION );
           }
           bBrowseSelFolder = TRUE;
           if(fodInfos->ofnInfos->Flags & OFN_EXPLORER)

Modified: trunk/reactos/dll/win32/comdlg32/filedlgbrowser.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comdlg32/filedlgbrowser.h?rev=74092&r1=74091&r2=74092&view=diff
==============================================================================
--- trunk/reactos/dll/win32/comdlg32/filedlgbrowser.h   [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/comdlg32/filedlgbrowser.h   [iso-8859-1] Sun Mar  5 
20:57:05 2017
@@ -81,6 +81,7 @@
        UINT sharevistring;
     } HookMsg;
 
+    BOOL ole_initialized;
 } FileOpenDlgInfos;
 
 /***********************************************************************

Modified: trunk/reactos/dll/win32/comdlg32/itemdlg.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comdlg32/itemdlg.c?rev=74092&r1=74091&r2=74092&view=diff
==============================================================================
--- trunk/reactos/dll/win32/comdlg32/itemdlg.c  [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/comdlg32/itemdlg.c  [iso-8859-1] Sun Mar  5 
20:57:05 2017
@@ -1958,7 +1958,7 @@
 
     if (umessage == WM_LBUTTONDOWN)
     {
-        FileDialogImpl *This = (FileDialogImpl*)GetPropW(hwnd, prop_this);
+        FileDialogImpl *This = GetPropW(hwnd, prop_this);
 
         SendMessageW(hwnd, BM_SETCHECK, BST_CHECKED, 0);
         show_opendropdown(This);
@@ -2051,7 +2051,7 @@
         SendMessageW(dropdown_hwnd, WM_SETFONT, 
(LPARAM)This->hfont_opendropdown, 0);
 
         /* Subclass button so we can handle LBUTTONDOWN */
-        SetPropW(dropdown_hwnd, prop_this, (HANDLE)This);
+        SetPropW(dropdown_hwnd, prop_this, This);
         SetPropW(dropdown_hwnd, prop_oldwndproc,
             (HANDLE)SetWindowLongPtrW(dropdown_hwnd, GWLP_WNDPROC, 
(LONG_PTR)dropdown_subclass_proc));
     }

Modified: trunk/reactos/media/doc/README.WINE
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=74092&r1=74091&r2=74092&view=diff
==============================================================================
--- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original)
+++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Sun Mar  5 20:57:05 2017
@@ -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-2.2
-reactos/dll/win32/comdlg32            # Synced to WineStaging-1.9.23
+reactos/dll/win32/comdlg32            # Synced to WineStaging-2.2
 reactos/dll/win32/compstui            # Synced to WineStaging-2.2
 reactos/dll/win32/credui              # Synced to WineStaging-2.2
 reactos/dll/win32/crypt32             # Synced to WineStaging-1.9.23


Reply via email to