1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2012-2013 - TortoiseGit
4 // Copyright (C) 2003-2007, 2012-2013 - 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.
33 CFindBar::~CFindBar(void)
38 LRESULT
CFindBar::DlgFunc(HWND
/*hwndDlg*/, UINT uMsg
, WPARAM wParam
, LPARAM
/*lParam*/)
44 m_hIcon
= (HICON
)::LoadImage(hResource
, MAKEINTRESOURCE(IDI_CANCELNORMAL
), IMAGE_ICON
, 0, 0, LR_DEFAULTCOLOR
);
45 SendMessage(GetDlgItem(*this, IDC_FINDEXIT
), BM_SETIMAGE
, IMAGE_ICON
, (LPARAM
)m_hIcon
);
49 return DoCommand(LOWORD(wParam
), HIWORD(wParam
));
55 LRESULT
CFindBar::DoCommand(int id
, int msg
)
57 bool bFindPrev
= false;
70 ::SendMessage(m_hParent
, COMMITMONITOR_FINDEXIT
, 0, 0);
77 SendMessage(m_hParent
, COMMITMONITOR_FINDRESET
, 0, 0);
86 void CFindBar::DoFind(bool bFindPrev
)
88 int len
= ::GetWindowTextLength(GetDlgItem(*this, IDC_FINDTEXT
));
89 std::unique_ptr
<TCHAR
[]> findtext(new TCHAR
[len
+ 1]);
90 if (!::GetWindowText(GetDlgItem(*this, IDC_FINDTEXT
), findtext
.get(), len
+ 1))
92 std::wstring ft
= std::wstring(findtext
.get());
93 const bool bCaseSensitive
= !!SendMessage(GetDlgItem(*this, IDC_MATCHCASECHECK
), BM_GETCHECK
, 0, NULL
);
94 const UINT message
= bFindPrev
? COMMITMONITOR_FINDMSGPREV
: COMMITMONITOR_FINDMSGNEXT
;
95 ::SendMessage(m_hParent
, message
, (WPARAM
)bCaseSensitive
, (LPARAM
)ft
.c_str());