OSDN Git Service

Allow NUL and \\.\NUL in paths specified as command line arguments (#2056)
[winmerge-jp/winmerge-jp.git] / Src / ConfirmFolderCopyDlg.cpp
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /**
3  * @file  ConfirmFolderCopyDlg.cpp
4  *
5  * @brief Implementation file for ConfirmFolderCopyDlg dialog
6  */
7
8 #include "stdafx.h"
9 #include "ConfirmFolderCopyDlg.h"
10
11 #ifdef _DEBUG
12 #define new DEBUG_NEW
13 #endif
14
15
16 // ConfirmFolderCopyDlg dialog
17
18 IMPLEMENT_DYNAMIC(ConfirmFolderCopyDlg, CTrDialog)
19 ConfirmFolderCopyDlg::ConfirmFolderCopyDlg(CWnd* pParent /*= nullptr*/)
20         : CTrDialog(ConfirmFolderCopyDlg::IDD, pParent)
21         , m_dontAskAgain(false)
22 {
23 }
24
25 ConfirmFolderCopyDlg::~ConfirmFolderCopyDlg()
26 {
27 }
28
29 void ConfirmFolderCopyDlg::DoDataExchange(CDataExchange* pDX)
30 {
31         CTrDialog::DoDataExchange(pDX);
32         //{{AFX_DATA_MAP(ConfirmFolderCopyDlg)
33         DDX_Text(pDX, IDC_FLDCONFIRM_FROM_TEXT, m_fromText);
34         DDX_Text(pDX, IDC_FLDCONFIRM_TO_TEXT, m_toText);
35         DDX_Text(pDX, IDC_FLDCONFIRM_FROM_PATH, m_fromPath);
36         DDX_Text(pDX, IDC_FLDCONFIRM_TO_PATH, m_toPath);
37         DDX_Text(pDX, IDC_FLDCONFIRM_QUERY, m_question);
38         DDX_Check(pDX, IDC_FLDCONFIRM_DONTASKAGAIN, m_dontAskAgain);
39         //}}AFX_DATA_MAP
40 }
41
42
43 BEGIN_MESSAGE_MAP(ConfirmFolderCopyDlg, CTrDialog)
44         ON_BN_CLICKED(IDNO, OnBnClickedNo)
45         ON_BN_CLICKED(IDYES, OnBnClickedYes)
46         ON_BN_CLICKED(IDC_FLDCONFIRM_DONTASKAGAIN, OnBnClickedDontAskAgain)
47 END_MESSAGE_MAP()
48
49
50 // ConfirmFolderCopyDlg message handlers
51
52 /**
53  * @brief Handler for WM_INITDIALOG; conventional location to initialize
54  * controls. At this point dialog and control windows exist.
55  */
56 BOOL ConfirmFolderCopyDlg::OnInitDialog() 
57 {
58         CTrDialog::OnInitDialog();
59
60         UINT storedDecision = AfxGetApp()->GetProfileInt(REGISTRY_SECTION_MESSAGEBOX, _T("FolderCopyConfirmDlgDontAskAgain"), IDNO);
61         if (storedDecision == IDYES)
62                 EndDialog(IDYES);
63         else
64         {
65                 // Load warning icon
66                 // TODO: we can have per-action icons?
67                 HICON icon = AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION);
68                 SendDlgItemMessage(IDC_FLDCONFIRM_ICON, STM_SETICON, (WPARAM)icon, 0L);
69
70                 if (!m_caption.empty())
71                         SetTitleText(m_caption);
72
73                 // setup handler for resizing this dialog       
74                 m_constraint.InitializeCurrentSize(this);
75                 m_constraint.DisallowHeightGrowth();
76                 m_constraint.SubclassWnd(); // install subclassing
77                 // persist size via registry
78                 m_constraint.LoadPosition(_T("ResizeableDialogs"), _T("FolderCopyConfirmDlg"), false);
79
80                 String strDontAskAgain = LoadResString(IDS_MESSAGEBOX_DONT_ASK_AGAIN);
81                 SetDlgItemText(IDC_FLDCONFIRM_DONTASKAGAIN, strDontAskAgain);
82         }
83
84         return TRUE;  // return TRUE unless you set the focus to a control
85                                   // EXCEPTION: OCX Property Pages should return FALSE
86 }
87
88 /**
89  * @brief Close dialog when No button is clicked.
90  */
91 void ConfirmFolderCopyDlg::OnBnClickedNo()
92 {
93         EndDialog(IDNO);
94 }
95
96 /**
97  * @brief Close dialog when Yes button is clicked.
98  */
99 void ConfirmFolderCopyDlg::OnBnClickedYes()
100 {
101         EndDialog(IDYES);
102 }
103
104 /**
105  * @brief Handle the "Don't ask again" checkbox, writing to the same registry key used by CMessageBoxDialog. 
106  * It doesn't use its algorithm for generating a value name, but it doesn't matter, since it won't collide
107  * with a value generated by CMessageBoxDialog and will also be reset by the Reset button in the Options dialog.
108  */
109 void ConfirmFolderCopyDlg::OnBnClickedDontAskAgain()
110 {
111         UpdateData();
112         AfxGetApp()->WriteProfileInt(REGISTRY_SECTION_MESSAGEBOX, _T("FolderCopyConfirmDlgDontAskAgain"),
113                 m_dontAskAgain ? IDYES : IDNO);
114 }