Fixed issue #3089: Show parent SHA1 on cherry picking a merge commit
[TortoiseGit.git] / src / TortoiseProc / FindBar.cpp
blob61ca952e0c3c1cc8d813e29fd5ed8be06ffe318c
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2015-2016 - TortoiseGit
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 "resource.h"
21 #include "FindBar.h"
23 UINT CFindBar::WM_FINDEXIT = RegisterWindowMessage(L"TORTOISEGIT_PATCHVIEW_FINDEXIT_MSG");
24 UINT CFindBar::WM_FINDNEXT = RegisterWindowMessage(L"TORTOISEGIT_PATCHVIEW_FINDNEXT_MSG");
25 UINT CFindBar::WM_FINDPREV = RegisterWindowMessage(L"TORTOISEGIT_PATCHVIEW_FINDPREV_MSG");
26 UINT CFindBar::WM_FINDRESET = RegisterWindowMessage(L"TORTOISEGIT_PATCHVIEW_FINDRESET_MSG");
28 IMPLEMENT_DYNAMIC(CFindBar, CDialog)
30 CFindBar::CFindBar(CWnd* pParent /*=nullptr*/)
31 : CDialog(CFindBar::IDD, pParent)
32 , m_hIcon(nullptr)
33 , m_bMatchCase(false)
37 CFindBar::~CFindBar(void)
39 DestroyIcon(m_hIcon);
42 BOOL CFindBar::OnInitDialog()
44 CDialog::OnInitDialog();
46 m_hIcon = (HICON)::LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_CANCELNORMAL), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
47 GetDlgItem(IDC_FINDEXIT)->SendMessage(BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_hIcon);
49 return TRUE; // return TRUE unless you set the focus to a control
52 void CFindBar::DoDataExchange(CDataExchange* pDX)
54 CDialog::DoDataExchange(pDX);
55 DDX_Text(pDX, IDC_FINDTEXT, m_sFindStr);
56 DDX_Check(pDX, IDC_MATCHCASECHECK, m_bMatchCase);
59 BEGIN_MESSAGE_MAP(CFindBar, CDialog)
60 ON_BN_CLICKED(IDC_FINDEXIT, &OnFindExit)
61 ON_BN_CLICKED(IDC_FINDNEXT, &OnFindNext)
62 ON_BN_CLICKED(IDC_FINDPREV, &OnFindPrev)
63 ON_EN_CHANGE(IDC_FINDTEXT, &OnFindTextChange)
64 END_MESSAGE_MAP()
66 void CFindBar::OnOK()
68 // Do nothing if enter is pressed
71 void CFindBar::OnCancel()
73 // hide the find bar on escape
74 OnFindExit();
77 void CFindBar::OnFindNext()
79 UpdateData(TRUE);
80 if (!m_sFindStr.IsEmpty())
81 GetParent()->SendMessage(WM_FINDNEXT);
84 void CFindBar::OnFindPrev()
86 UpdateData(TRUE);
87 if (!m_sFindStr.IsEmpty())
88 GetParent()->SendMessage(WM_FINDPREV);
91 void CFindBar::OnFindExit()
93 GetParent()->SendMessage(WM_FINDEXIT);
96 void CFindBar::OnFindTextChange()
98 GetParent()->SendMessage(WM_FINDRESET);
99 OnFindNext();