No need to explicitly initialize CString and use Empty() for clearing CString
[TortoiseGit.git] / src / TortoiseProc / Settings / ToolAssocDlg.cpp
blobae43e09af7dc4c6684621f2ba9749111e45aa164
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007, 2009, 2011 - 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 "TortoiseProc.h"
21 #include "ToolAssocDlg.h"
22 #include "AppUtils.h"
24 IMPLEMENT_DYNAMIC(CToolAssocDlg, CDialog)
25 CToolAssocDlg::CToolAssocDlg(const CString& type, bool add, CWnd* pParent /*=NULL*/)
26 : CDialog(CToolAssocDlg::IDD, pParent)
27 , m_sType(type)
28 , m_bAdd(add)
32 CToolAssocDlg::~CToolAssocDlg()
36 void CToolAssocDlg::DoDataExchange(CDataExchange* pDX)
38 CDialog::DoDataExchange(pDX);
39 DDX_Text(pDX, IDC_EXTEDIT, m_sExtension);
40 DDX_Text(pDX, IDC_TOOLEDIT, m_sTool);
42 if (pDX->m_bSaveAndValidate)
44 if (m_sExtension.Find('/')<0)
46 m_sExtension.TrimLeft(_T("*"));
52 BEGIN_MESSAGE_MAP(CToolAssocDlg, CDialog)
53 ON_BN_CLICKED(IDC_TOOLBROWSE, OnBnClickedToolbrowse)
54 END_MESSAGE_MAP()
56 BOOL CToolAssocDlg::OnInitDialog()
58 CDialog::OnInitDialog();
60 EnableToolTips();
61 m_tooltips.Create(this);
63 CString title;
64 if (m_sType == _T("Diff"))
66 title.LoadString(m_bAdd ? IDS_DLGTITLE_ADD_DIFF_TOOL : IDS_DLGTITLE_EDIT_DIFF_TOOL);
67 m_tooltips.AddTool(IDC_TOOLEDIT, IDS_SETTINGS_EXTDIFF_TT);
69 else
71 title.LoadString(m_bAdd ? IDS_DLGTITLE_ADD_MERGE_TOOL : IDS_DLGTITLE_EDIT_MERGE_TOOL);
72 m_tooltips.AddTool(IDC_TOOLEDIT, IDS_SETTINGS_EXTMERGE_TT);
75 SetWindowText(title);
76 SHAutoComplete(::GetDlgItem(m_hWnd, IDC_TOOLEDIT), SHACF_FILESYSTEM | SHACF_FILESYS_ONLY);
78 UpdateData(FALSE);
79 return TRUE;
82 BOOL CToolAssocDlg::PreTranslateMessage(MSG* pMsg)
84 m_tooltips.RelayEvent(pMsg);
85 return CDialog::PreTranslateMessage(pMsg);
88 void CToolAssocDlg::OnBnClickedToolbrowse()
90 UpdateData(TRUE);
91 if (CAppUtils::FileOpenSave(m_sTool, NULL, IDS_SETTINGS_SELECTDIFF, IDS_PROGRAMSFILEFILTER, true, m_hWnd))
93 UpdateData(FALSE);