https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9c5017808a5fe1f5ad7f3df9812b9907c077adb5

commit 9c5017808a5fe1f5ad7f3df9812b9907c077adb5
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Thu Jan 30 08:32:21 2020 +0900
Commit:     GitHub <[email protected]>
CommitDate: Thu Jan 30 08:32:21 2020 +0900

    [SHELLEXT][ZIPFLDR] Use CStringA::FormatMessage (#2287)
    
    Simplify our code.
---
 dll/shellext/zipfldr/CConfirmReplace.cpp | 18 ++++--------------
 dll/shellext/zipfldr/CZipPassword.cpp    | 17 +++--------------
 2 files changed, 7 insertions(+), 28 deletions(-)

diff --git a/dll/shellext/zipfldr/CConfirmReplace.cpp 
b/dll/shellext/zipfldr/CConfirmReplace.cpp
index 4f51ee6bb69..8ee027a52ec 100644
--- a/dll/shellext/zipfldr/CConfirmReplace.cpp
+++ b/dll/shellext/zipfldr/CConfirmReplace.cpp
@@ -25,21 +25,11 @@ public:
         HICON hIcon = LoadIcon(NULL, IDI_EXCLAMATION);
         SendDlgItemMessage(IDC_EXCLAMATION_ICON, STM_SETICON, (WPARAM)hIcon);
 
-        /* Our CString does not support FormatMessage yet */
-        CStringA message(MAKEINTRESOURCE(IDS_OVERWRITEFILE_TEXT));
-        CHeapPtr<CHAR, CLocalAllocator> formatted;
+        CStringA message;
+        message.FormatMessage(IDS_OVERWRITEFILE_TEXT, m_Filename.GetString());
+        ::SetDlgItemTextA(m_hWnd, IDC_MESSAGE, message);
 
-        DWORD_PTR args[2] =
-        {
-            (DWORD_PTR)m_Filename.GetString(),
-            NULL
-        };
-
-        ::FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_ARGUMENT_ARRAY,
-                         message, 0, 0, (LPSTR)&formatted, 0, (va_list*)args);
-
-        ::SetDlgItemTextA(m_hWnd, IDC_MESSAGE, formatted);
-        return 0;
+        return TRUE;
     }
 
     LRESULT OnButton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
diff --git a/dll/shellext/zipfldr/CZipPassword.cpp 
b/dll/shellext/zipfldr/CZipPassword.cpp
index 99c896029d0..0a1964a23d1 100644
--- a/dll/shellext/zipfldr/CZipPassword.cpp
+++ b/dll/shellext/zipfldr/CZipPassword.cpp
@@ -33,20 +33,9 @@ public:
         }
         else
         {
-            /* Our CString does not support FormatMessage yet */
-            CStringA message(MAKEINTRESOURCE(IDS_PASSWORD_FILE_TEXT));
-            CHeapPtr<CHAR, CLocalAllocator> formatted;
-
-            DWORD_PTR args[2] =
-            {
-                (DWORD_PTR)m_Filename.GetString(),
-                NULL
-            };
-
-            ::FormatMessageA(FORMAT_MESSAGE_FROM_STRING | 
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_ARGUMENT_ARRAY,
-                             message, 0, 0, (LPSTR)&formatted, 0, 
(va_list*)args);
-
-            ::SetDlgItemTextA(m_hWnd, IDC_MESSAGE, formatted);
+            CStringA message;
+            message.FormatMessage(IDS_PASSWORD_FILE_TEXT, 
m_Filename.GetString());
+            ::SetDlgItemTextA(m_hWnd, IDC_MESSAGE, message);
         }
         return TRUE;
     }

Reply via email to