1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * @file ConfirmFolderCopyDlg.cpp
5 * @brief Implementation file for ConfirmFolderCopyDlg dialog
9 #include "ConfirmFolderCopyDlg.h"
16 // ConfirmFolderCopyDlg dialog
18 IMPLEMENT_DYNAMIC(ConfirmFolderCopyDlg, CTrDialog)
19 ConfirmFolderCopyDlg::ConfirmFolderCopyDlg(CWnd* pParent /*= nullptr*/)
20 : CTrDialog(ConfirmFolderCopyDlg::IDD, pParent)
21 , m_dontAskAgain(false)
25 ConfirmFolderCopyDlg::~ConfirmFolderCopyDlg()
29 void ConfirmFolderCopyDlg::DoDataExchange(CDataExchange* pDX)
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);
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)
50 // ConfirmFolderCopyDlg message handlers
53 * @brief Handler for WM_INITDIALOG; conventional location to initialize
54 * controls. At this point dialog and control windows exist.
56 BOOL ConfirmFolderCopyDlg::OnInitDialog()
58 CTrDialog::OnInitDialog();
60 UINT storedDecision = AfxGetApp()->GetProfileInt(REGISTRY_SECTION_MESSAGEBOX, _T("FolderCopyConfirmDlgDontAskAgain"), IDNO);
61 if (storedDecision == IDYES)
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);
70 if (!m_caption.empty())
71 SetTitleText(m_caption);
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);
80 String strDontAskAgain = LoadResString(IDS_MESSAGEBOX_DONT_ASK_AGAIN);
81 SetDlgItemText(IDC_FLDCONFIRM_DONTASKAGAIN, strDontAskAgain);
84 return TRUE; // return TRUE unless you set the focus to a control
85 // EXCEPTION: OCX Property Pages should return FALSE
89 * @brief Close dialog when No button is clicked.
91 void ConfirmFolderCopyDlg::OnBnClickedNo()
97 * @brief Close dialog when Yes button is clicked.
99 void ConfirmFolderCopyDlg::OnBnClickedYes()
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.
109 void ConfirmFolderCopyDlg::OnBnClickedDontAskAgain()
112 AfxGetApp()->WriteProfileInt(REGISTRY_SECTION_MESSAGEBOX, _T("FolderCopyConfirmDlgDontAskAgain"),
113 m_dontAskAgain ? IDYES : IDNO);