https://git.reactos.org/?p=reactos.git;a=commitdiff;h=410320df06e5b7c53ccd1…
commit 410320df06e5b7c53ccd1d7c1e195b42456f1124
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Wed Feb 27 22:18:32 2019 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Wed Mar 6 23:09:35 2019 +0100
[ZIPFLDR] Move CConfirmReplace to a new file
---
dll/shellext/zipfldr/CConfirmReplace.cpp | 77 ++++++++++++++++++++++++++++
dll/shellext/zipfldr/CMakeLists.txt | 1 +
dll/shellext/zipfldr/CZipExtract.cpp | 86 ++------------------------------
3 files changed, 83 insertions(+), 81 deletions(-)
diff --git a/dll/shellext/zipfldr/CConfirmReplace.cpp
b/dll/shellext/zipfldr/CConfirmReplace.cpp
new file mode 100644
index 0000000000..93edf99570
--- /dev/null
+++ b/dll/shellext/zipfldr/CConfirmReplace.cpp
@@ -0,0 +1,77 @@
+/*
+ * PROJECT: ReactOS Zip Shell Extension
+ * LICENSE: GPL-2.0+ (
https://spdx.org/licenses/GPL-2.0+)
+ * PURPOSE: Ask the user to replace a file
+ * COPYRIGHT: Copyright 2017-2019 Mark Jansen (mark.jansen(a)reactos.org)
+ */
+
+#include "precomp.h"
+
+class CConfirmReplace : public CDialogImpl<CConfirmReplace>
+{
+private:
+ CStringA m_Filename;
+public:
+
+ CConfirmReplace(const char* filename)
+ {
+ m_Filename = filename;
+ }
+
+ LRESULT OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
+ {
+ CenterWindow(GetParent());
+
+ 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;
+
+ 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;
+ }
+
+ LRESULT OnButton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
+ {
+ EndDialog(wID);
+ return 0;
+ }
+
+public:
+ enum { IDD = IDD_CONFIRM_FILE_REPLACE };
+
+ BEGIN_MSG_MAP(CConfirmReplace)
+ MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
+ COMMAND_ID_HANDLER(IDYES, OnButton)
+ COMMAND_ID_HANDLER(IDYESALL, OnButton)
+ COMMAND_ID_HANDLER(IDNO, OnButton)
+ COMMAND_ID_HANDLER(IDCANCEL, OnButton)
+ END_MSG_MAP()
+};
+
+
+eZipConfirmResponse _CZipAskReplace(HWND hDlg, PCSTR FullPath)
+{
+ PCSTR Filename = PathFindFileNameA(FullPath);
+ CConfirmReplace confirm(Filename);
+ INT_PTR Result = confirm.DoModal(hDlg);
+ switch (Result)
+ {
+ case IDYES: return eYes;
+ case IDYESALL: return eYesToAll;
+ default:
+ case IDNO: return eNo;
+ case IDCANCEL: return eCancel;
+ }
+}
diff --git a/dll/shellext/zipfldr/CMakeLists.txt b/dll/shellext/zipfldr/CMakeLists.txt
index d491f1d7c2..86a1b9c289 100644
--- a/dll/shellext/zipfldr/CMakeLists.txt
+++ b/dll/shellext/zipfldr/CMakeLists.txt
@@ -24,6 +24,7 @@ list(APPEND SOURCE
zippidl.cpp
zippidl.hpp
IZip.hpp
+ CConfirmReplace.cpp
CExplorerCommand.cpp
CEnumZipContents.cpp
CFolderViewCB.cpp
diff --git a/dll/shellext/zipfldr/CZipExtract.cpp b/dll/shellext/zipfldr/CZipExtract.cpp
index baa0b308fc..a95f8ba108 100644
--- a/dll/shellext/zipfldr/CZipExtract.cpp
+++ b/dll/shellext/zipfldr/CZipExtract.cpp
@@ -66,82 +66,6 @@ public:
return uf;
}
- class CConfirmReplace : public CDialogImpl<CConfirmReplace>
- {
- private:
- CStringA m_Filename;
- public:
- enum DialogResult
- {
- Yes,
- YesToAll,
- No,
- Cancel
- };
-
- static DialogResult ShowDlg(HWND hDlg, PCSTR FullPath)
- {
- PCSTR Filename = PathFindFileNameA(FullPath);
- CConfirmReplace confirm(Filename);
- INT_PTR Result = confirm.DoModal(hDlg);
- switch (Result)
- {
- case IDYES: return Yes;
- case IDYESALL: return YesToAll;
- default:
- case IDNO: return No;
- case IDCANCEL: return Cancel;
- }
- }
-
- CConfirmReplace(const char* filename)
- {
- m_Filename = filename;
- }
-
- LRESULT OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled)
- {
- CenterWindow(GetParent());
-
- 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;
-
- 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;
- }
-
- LRESULT OnButton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
- {
- EndDialog(wID);
- return 0;
- }
-
- public:
- enum { IDD = IDD_CONFIRM_FILE_REPLACE };
-
- BEGIN_MSG_MAP(CConfirmReplace)
- MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
- COMMAND_ID_HANDLER(IDYES, OnButton)
- COMMAND_ID_HANDLER(IDYESALL, OnButton)
- COMMAND_ID_HANDLER(IDNO, OnButton)
- COMMAND_ID_HANDLER(IDCANCEL, OnButton)
- END_MSG_MAP()
- };
-
-
class CExtractSettingsPage : public CPropertyPageImpl<CExtractSettingsPage>
{
private:
@@ -405,17 +329,17 @@ public:
bool bOverwrite = bOverwriteAll;
if (!bOverwriteAll)
{
- CConfirmReplace::DialogResult Result =
CConfirmReplace::ShowDlg(hDlg, FullPath);
+ eZipConfirmResponse Result = _CZipAskReplace(hDlg, FullPath);
switch (Result)
{
- case CConfirmReplace::YesToAll:
+ case eYesToAll:
bOverwriteAll = true;
- case CConfirmReplace::Yes:
+ case eYes:
bOverwrite = true;
break;
- case CConfirmReplace::No:
+ case eNo:
break;
- case CConfirmReplace::Cancel:
+ case eCancel:
unzCloseCurrentFile(uf);
Close();
return false;