https://git.reactos.org/?p=reactos.git;a=commitdiff;h=87d276f05d673e53a413269099eeb1e7882ec825

commit 87d276f05d673e53a413269099eeb1e7882ec825
Author: Katayama Hirofumi MZ <[email protected]>
AuthorDate: Sat Nov 25 18:27:20 2017 +0900

    [SHELL32] Don't show error when closing disk prop sheet (#144)
    
    CORE-14035
---
 dll/win32/shell32/dialogs/drive.cpp         | 16 ++++++++++------
 dll/win32/shell32/dialogs/fprop.cpp         |  3 ++-
 dll/win32/shell32/folders/CDrivesFolder.cpp |  4 ++--
 dll/win32/shell32/wine/shell32_main.h       |  2 +-
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/dll/win32/shell32/dialogs/drive.cpp 
b/dll/win32/shell32/dialogs/drive.cpp
index a5919f027f..3afbe80d8c 100644
--- a/dll/win32/shell32/dialogs/drive.cpp
+++ b/dll/win32/shell32/dialogs/drive.cpp
@@ -2,6 +2,7 @@
  *                 Shell Library Functions
  *
  * Copyright 2005 Johannes Anderwald
+ * Copyright 2017 Katayama Hirofumi MZ
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -127,7 +128,7 @@ typedef struct _DRIVE_PROP_PAGE
     UINT DriveType;
 } DRIVE_PROP_PAGE;
 
-BOOL
+HRESULT
 SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST pidlFolder, 
PCUITEMID_CHILD_ARRAY apidl)
 {
     HPSXA hpsx = NULL;
@@ -145,7 +146,7 @@ SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST 
pidlFolder, PCUITEMID_CHI
 
     LPITEMIDLIST completePidl = ILCombine(pidlFolder, apidl[0]);
     if (!completePidl)
-        return FALSE;
+        return E_OUTOFMEMORY;
 
     if (ILGetDisplayNameExW(NULL, completePidl, wszName, ILGDN_NORMAL))
     {
@@ -179,16 +180,19 @@ SH_ShowDriveProperties(WCHAR *pwszDrive, LPCITEMIDLIST 
pidlFolder, PCUITEMID_CHI
             SHAddFromPropSheetExtArray(hpsx, 
(LPFNADDPROPSHEETPAGE)AddPropSheetPageCallback, (LPARAM)&psh);
     }
 
-    HWND hwnd = (HWND)PropertySheetW(&psh);
+    // NOTE: Currently property sheet is modal. If we make it modeless, then 
it returns HWND.
+    INT_PTR ret = PropertySheetW(&psh);
 
     if (hpsx)
         SHDestroyPropSheetExtArray(hpsx);
     if (pDrvDefExt)
         pDrvDefExt->Release();
 
-    if (!hwnd)
-        return FALSE;
-    return TRUE;
+    if (ret > 0)
+        return S_OK;
+    if (ret == 0)
+        return S_FALSE;
+    return E_FAIL;
 }
 
 static VOID
diff --git a/dll/win32/shell32/dialogs/fprop.cpp 
b/dll/win32/shell32/dialogs/fprop.cpp
index ede236fa85..989a9ce6c1 100644
--- a/dll/win32/shell32/dialogs/fprop.cpp
+++ b/dll/win32/shell32/dialogs/fprop.cpp
@@ -3,6 +3,7 @@
  *
  * Copyright 2005 Johannes Anderwald
  * Copyright 2012 Rafal Harabien
+ * Copyright 2017 Katayama Hirofumi MZ
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -117,7 +118,7 @@ SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST 
pidlFolder, PCUITEMID_CH
 
     /* Handle drives */
     if (PathIsRootW(wszPath))
-        return SH_ShowDriveProperties(wszPath, pidlFolder, apidl);
+        return SUCCEEDED(SH_ShowDriveProperties(wszPath, pidlFolder, apidl));
 
     /* Handle files and folders */
     PROPSHEETHEADERW Header;
diff --git a/dll/win32/shell32/folders/CDrivesFolder.cpp 
b/dll/win32/shell32/folders/CDrivesFolder.cpp
index 701a10643f..196165597f 100644
--- a/dll/win32/shell32/folders/CDrivesFolder.cpp
+++ b/dll/win32/shell32/folders/CDrivesFolder.cpp
@@ -215,9 +215,9 @@ HRESULT CALLBACK DrivesContextMenuCallback(IShellFolder 
*psf,
 
         if (wParam == DFM_CMD_PROPERTIES)
         {
-            if (!SH_ShowDriveProperties(wszBuf, pidlFolder, apidl))
+            hr = SH_ShowDriveProperties(wszBuf, pidlFolder, apidl);
+            if (FAILED(hr))
             {
-                hr = E_FAIL;
                 dwError = ERROR_CAN_NOT_COMPLETE;
                 nStringID = IDS_CANTSHOWPROPERTIES;
             }
diff --git a/dll/win32/shell32/wine/shell32_main.h 
b/dll/win32/shell32/wine/shell32_main.h
index 8e17caf421..170d844b4b 100644
--- a/dll/win32/shell32/wine/shell32_main.h
+++ b/dll/win32/shell32/wine/shell32_main.h
@@ -184,7 +184,7 @@ BOOL SHELL_IsShortcut(LPCITEMIDLIST) DECLSPEC_HIDDEN;
 INT_PTR CALLBACK SH_FileGeneralDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, 
LPARAM lParam);
 INT_PTR CALLBACK SH_FileVersionDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, 
LPARAM lParam);
 HPROPSHEETPAGE SH_CreatePropertySheetPage(WORD wDialogId, DLGPROC pfnDlgProc, 
LPARAM lParam, LPCWSTR pwszTitle);
-BOOL SH_ShowDriveProperties(WCHAR *drive, LPCITEMIDLIST pidlFolder, 
PCUITEMID_CHILD_ARRAY apidl);
+HRESULT SH_ShowDriveProperties(WCHAR *drive, LPCITEMIDLIST pidlFolder, 
PCUITEMID_CHILD_ARRAY apidl);
 BOOL SH_ShowRecycleBinProperties(WCHAR sDrive);
 BOOL SH_ShowPropertiesDialog(LPCWSTR pwszPath, LPCITEMIDLIST pidlFolder, 
PCUITEMID_CHILD_ARRAY apidl);
 LPWSTR SH_FormatFileSizeWithBytes(PULARGE_INTEGER lpQwSize, LPWSTR pszBuf, 
UINT cchBuf);

Reply via email to