No need to explicitly initialize CString and use Empty() for clearing CString
[TortoiseGit.git] / src / TortoiseMerge / RegexFilterDlg.cpp
blobef1877a046d4df561b635c2c022c1459e6338681
1 // TortoiseMerge - a Diff/Patch program
3 // Copyright (C) 2013-2014 - TortoiseSVN
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software Foundation,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include "stdafx.h"
20 #include "TortoiseMerge.h"
21 #include "RegexFilterDlg.h"
22 #include <afxdialogex.h>
23 #include <regex>
26 // CRegexFilterDlg dialog
28 IMPLEMENT_DYNAMIC(CRegexFilterDlg, CDialogEx)
30 CRegexFilterDlg::CRegexFilterDlg(CWnd* pParent /*=NULL*/)
31 : CDialogEx(CRegexFilterDlg::IDD, pParent)
35 CRegexFilterDlg::~CRegexFilterDlg()
39 void CRegexFilterDlg::DoDataExchange(CDataExchange* pDX)
41 CDialogEx::DoDataExchange(pDX);
42 DDX_Text(pDX, IDC_NAME, m_sName);
43 DDX_Text(pDX, IDC_REGEX, m_sRegex);
44 DDX_Text(pDX, IDC_REPLACE, m_sReplace);
48 BEGIN_MESSAGE_MAP(CRegexFilterDlg, CDialogEx)
49 END_MESSAGE_MAP()
52 // CRegexFilterDlg message handlers
55 BOOL CRegexFilterDlg::OnInitDialog()
57 CDialogEx::OnInitDialog();
59 UpdateData(FALSE);
61 GetDlgItem(IDC_NAME)->SetFocus();
62 return FALSE; // return TRUE unless you set the focus to a control
63 // EXCEPTION: OCX Property Pages should return FALSE
66 void CRegexFilterDlg::OnOK()
68 UpdateData();
70 try
72 std::wregex r1 = std::wregex(m_sRegex);
73 UNREFERENCED_PARAMETER(r1);
75 catch (std::exception)
77 ShowEditBalloon(IDC_REGEX, IDS_ERR_INVALIDREGEX, IDS_ERR_ERROR);
78 return;
81 CDialog::OnOK();
84 void CRegexFilterDlg::ShowEditBalloon(UINT nIdControl, UINT nIdText, UINT nIdTitle, int nIcon)
86 CString text = CString(MAKEINTRESOURCE(nIdText));
87 CString title = CString(MAKEINTRESOURCE(nIdTitle));
88 EDITBALLOONTIP bt;
89 bt.cbStruct = sizeof(bt);
90 bt.pszText = text;
91 bt.pszTitle = title;
92 bt.ttiIcon = nIcon;
93 SendDlgItemMessage(nIdControl, EM_SHOWBALLOONTIP, 0, (LPARAM)&bt);