Correctly deallocate buffer
[TortoiseGit.git] / src / TortoiseMerge / FindDlg.cpp
blob47fcd570f687d01760d4db6d07540d6803c43382
1 // TortoiseGitMerge - a Diff/Patch program
3 // Copyright (C) 2006, 2011-2012 - 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 "FindDlg.h"
24 // CFindDlg dialog
26 IMPLEMENT_DYNAMIC(CFindDlg, CDialog)
28 CFindDlg::CFindDlg(CWnd* pParent /*=NULL*/)
29 : CDialog(CFindDlg::IDD, pParent)
30 , m_pParent(pParent)
31 , m_bTerminating(false)
32 , m_bFindNext(false)
33 , m_bMatchCase(FALSE)
34 , m_bLimitToDiffs(FALSE)
35 , m_bWholeWord(FALSE)
36 , m_FindMsg(0)
40 CFindDlg::~CFindDlg()
44 void CFindDlg::DoDataExchange(CDataExchange* pDX)
46 CDialog::DoDataExchange(pDX);
47 DDX_Check(pDX, IDC_MATCHCASE, m_bMatchCase);
48 DDX_Check(pDX, IDC_LIMITTODIFFS, m_bLimitToDiffs);
49 DDX_Check(pDX, IDC_WHOLEWORD, m_bWholeWord);
50 DDX_Control(pDX, IDC_FINDCOMBO, m_FindCombo);
54 BEGIN_MESSAGE_MAP(CFindDlg, CDialog)
55 ON_CBN_EDITCHANGE(IDC_FINDCOMBO, &CFindDlg::OnCbnEditchangeFindcombo)
56 END_MESSAGE_MAP()
59 // CFindDlg message handlers
61 void CFindDlg::OnCancel()
63 m_bTerminating = true;
64 if (m_pParent)
65 m_pParent->SendMessage(m_FindMsg);
66 else if (GetParent())
67 GetParent()->SendMessage(m_FindMsg);
68 DestroyWindow();
71 void CFindDlg::PostNcDestroy()
73 delete this;
76 void CFindDlg::OnOK()
78 UpdateData();
79 m_FindCombo.SaveHistory();
81 if (m_FindCombo.GetString().IsEmpty())
82 return;
83 m_bFindNext = true;
84 if (m_pParent)
85 m_pParent->SendMessage(m_FindMsg);
86 else if (GetParent())
87 GetParent()->SendMessage(m_FindMsg);
88 m_bFindNext = false;
91 BOOL CFindDlg::OnInitDialog()
93 CDialog::OnInitDialog();
94 m_FindMsg = RegisterWindowMessage(FINDMSGSTRING);
96 m_FindCombo.DisableTrimming();
97 m_FindCombo.LoadHistory(_T("Software\\TortoiseGitMerge\\History\\Find"), _T("Search"));
99 m_FindCombo.SetFocus();
101 return FALSE;
104 void CFindDlg::OnCbnEditchangeFindcombo()
106 UpdateData();
107 GetDlgItem(IDOK)->EnableWindow(!m_FindCombo.GetString().IsEmpty());