reactos/dll/shellext/zipfldr/CConfirmReplace.cpp
Katayama Hirofumi MZ bf2cec186c
[ZIPFLDR] Support UTF-8 Zip extraction (#5411)
- Extend some Ansi strings to Wide strings.
- Check the UTF-8 flag (1 << 11). If UTF-8, then use CP_UTF8.
- s/LPCWSTR/PCWSTR/.
- s/LPWSTR/PWSTR/.
CORE-16668
2023-07-17 20:12:45 +09:00

66 lines
1.8 KiB
C++

/*
* 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@reactos.org)
* Copyright 2023 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
*/
#include "precomp.h"
class CConfirmReplace : public CDialogImpl<CConfirmReplace>
{
private:
CStringW m_Filename;
public:
CConfirmReplace(PCWSTR 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);
CStringW message;
message.FormatMessage(IDS_OVERWRITEFILE_TEXT, m_Filename.GetString());
::SetDlgItemTextW(m_hWnd, IDC_MESSAGE, message);
return TRUE;
}
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, PCWSTR FullPath)
{
PCWSTR Filename = PathFindFileNameW(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;
}
}