OSDN Git Service

autoit.cpp - Macros >> User 1 ..... Variable >> User 2 (#749) (2)
[winmerge-jp/winmerge-jp.git] / Src / ConfirmFolderCopyDlg.cpp
index afc77d6..06480de 100644 (file)
@@ -18,6 +18,7 @@
 IMPLEMENT_DYNAMIC(ConfirmFolderCopyDlg, CTrDialog)
 ConfirmFolderCopyDlg::ConfirmFolderCopyDlg(CWnd* pParent /*= nullptr*/)
        : CTrDialog(ConfirmFolderCopyDlg::IDD, pParent)
+       , m_dontAskAgain(false)
 {
 }
 
@@ -34,6 +35,7 @@ void ConfirmFolderCopyDlg::DoDataExchange(CDataExchange* pDX)
        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
 }
 
@@ -41,6 +43,7 @@ void ConfirmFolderCopyDlg::DoDataExchange(CDataExchange* pDX)
 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()
 
 
@@ -54,23 +57,32 @@ BOOL ConfirmFolderCopyDlg::OnInitDialog()
 {
        CTrDialog::OnInitDialog();
 
-       // 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())
-               SetWindowText(m_caption.c_str());
-
-       // 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);
+       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())
+                       SetWindowText(m_caption.c_str());
+
+               // 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);
+               GetDlgItem(IDC_FLDCONFIRM_DONTASKAGAIN)->SetWindowText(strDontAskAgain.c_str());
+       }
 
        return TRUE;  // return TRUE unless you set the focus to a control
-                     // EXCEPTION: OCX Property Pages should return FALSE
+                                 // EXCEPTION: OCX Property Pages should return FALSE
 }
 
 /**
@@ -88,3 +100,17 @@ 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();
+       if (m_dontAskAgain)
+               AfxGetApp()->WriteProfileInt(REGISTRY_SECTION_MESSAGEBOX, _T("FolderCopyConfirmDlgDontAskAgain"), IDYES);
+       else
+               AfxGetApp()->WriteProfileInt(REGISTRY_SECTION_MESSAGEBOX, _T("FolderCopyConfirmDlgDontAskAgain"), IDNO);
+}