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.
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
)
37 CFindBar::~CFindBar(void)
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
)
68 // Do nothing if enter is pressed
71 void CFindBar::OnCancel()
73 // hide the find bar on escape
77 void CFindBar::OnFindNext()
80 if (!m_sFindStr
.IsEmpty())
81 GetParent()->SendMessage(WM_FINDNEXT
);
84 void CFindBar::OnFindPrev()
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
);