Pass HWND to CGitDiff
[TortoiseGit.git] / src / TortoiseProc / Settings / ToolAssocDlg.cpp
blobe7297506bafe2b9b4ecd06ce18a60a6ba7382dca
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2016 - TortoiseGit
4 // Copyright (C) 2003-2007, 2009, 2011 - TortoiseSVN
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "stdafx.h"
21 #include "TortoiseProc.h"
22 #include "ToolAssocDlg.h"
23 #include "AppUtils.h"
25 IMPLEMENT_DYNAMIC(CToolAssocDlg, CDialog)
26 CToolAssocDlg::CToolAssocDlg(const CString& type, bool add, CWnd* pParent /*=nullptr*/)
27 : CDialog(CToolAssocDlg::IDD, pParent)
28 , m_sType(type)
29 , m_bAdd(add)
33 CToolAssocDlg::~CToolAssocDlg()
37 void CToolAssocDlg::DoDataExchange(CDataExchange* pDX)
39 CDialog::DoDataExchange(pDX);
40 DDX_Text(pDX, IDC_EXTEDIT, m_sExtension);
41 DDX_Text(pDX, IDC_TOOLEDIT, m_sTool);
43 if (pDX->m_bSaveAndValidate)
45 if (m_sExtension.Find(L'/') < 0)
46 m_sExtension.TrimLeft(L'*');
51 BEGIN_MESSAGE_MAP(CToolAssocDlg, CDialog)
52 ON_BN_CLICKED(IDC_TOOLBROWSE, OnBnClickedToolbrowse)
53 END_MESSAGE_MAP()
55 BOOL CToolAssocDlg::OnInitDialog()
57 CDialog::OnInitDialog();
59 EnableToolTips();
60 m_tooltips.Create(this);
62 CString title;
63 if (m_sType == L"Diff")
65 title.LoadString(m_bAdd ? IDS_DLGTITLE_ADD_DIFF_TOOL : IDS_DLGTITLE_EDIT_DIFF_TOOL);
66 m_tooltips.AddTool(IDC_TOOLEDIT, IDS_SETTINGS_EXTDIFF_TT);
68 else
70 title.LoadString(m_bAdd ? IDS_DLGTITLE_ADD_MERGE_TOOL : IDS_DLGTITLE_EDIT_MERGE_TOOL);
71 m_tooltips.AddTool(IDC_TOOLEDIT, IDS_SETTINGS_EXTMERGE_TT);
74 SetWindowText(title);
75 SHAutoComplete(::GetDlgItem(m_hWnd, IDC_TOOLEDIT), SHACF_FILESYSTEM | SHACF_FILESYS_ONLY);
77 UpdateData(FALSE);
78 return TRUE;
81 BOOL CToolAssocDlg::PreTranslateMessage(MSG* pMsg)
83 m_tooltips.RelayEvent(pMsg);
84 return CDialog::PreTranslateMessage(pMsg);
87 void CToolAssocDlg::OnBnClickedToolbrowse()
89 UpdateData(TRUE);
90 CString filename = m_sTool;
91 if (!PathFileExists(filename))
92 filename.Empty();
93 if (!CAppUtils::FileOpenSave(filename, nullptr, IDS_SETTINGS_SELECTDIFF, IDS_PROGRAMSFILEFILTER, true, m_hWnd))
94 return;
96 m_sTool = filename;
97 UpdateData(FALSE);