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