1 /* 2 * PROJECT: ReactOS Zip Shell Extension 3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 * PURPOSE: Ask the user to replace a file 5 * COPYRIGHT: Copyright 2017-2019 Mark Jansen (mark.jansen@reactos.org) 6 */ 7 8 #include "precomp.h" 9 10 class CConfirmReplace : public CDialogImpl<CConfirmReplace> 11 { 12 private: 13 CStringA m_Filename; 14 public: 15 16 CConfirmReplace(const char* filename) 17 : m_Filename(filename) 18 { 19 } 20 21 LRESULT OnInitDialog(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) 22 { 23 CenterWindow(GetParent()); 24 25 HICON hIcon = LoadIcon(NULL, IDI_EXCLAMATION); 26 SendDlgItemMessage(IDC_EXCLAMATION_ICON, STM_SETICON, (WPARAM)hIcon); 27 28 CStringA message; 29 message.FormatMessage(IDS_OVERWRITEFILE_TEXT, m_Filename.GetString()); 30 ::SetDlgItemTextA(m_hWnd, IDC_MESSAGE, message); 31 32 return TRUE; 33 } 34 35 LRESULT OnButton(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) 36 { 37 EndDialog(wID); 38 return 0; 39 } 40 41 public: 42 enum { IDD = IDD_CONFIRM_FILE_REPLACE }; 43 44 BEGIN_MSG_MAP(CConfirmReplace) 45 MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) 46 COMMAND_ID_HANDLER(IDYES, OnButton) 47 COMMAND_ID_HANDLER(IDYESALL, OnButton) 48 COMMAND_ID_HANDLER(IDNO, OnButton) 49 COMMAND_ID_HANDLER(IDCANCEL, OnButton) 50 END_MSG_MAP() 51 }; 52 53 54 eZipConfirmResponse _CZipAskReplace(HWND hDlg, PCSTR FullPath) 55 { 56 PCSTR Filename = PathFindFileNameA(FullPath); 57 CConfirmReplace confirm(Filename); 58 INT_PTR Result = confirm.DoModal(hDlg); 59 switch (Result) 60 { 61 case IDYES: return eYes; 62 case IDYESALL: return eYesToAll; 63 default: 64 case IDNO: return eNo; 65 case IDCANCEL: return eCancel; 66 } 67 } 68