use the right case for registry.h and stop using relative paths in the source files
[TortoiseGit.git] / src / TortoiseUDiff / FindBar.cpp
blob3195afd612442930139cd47775cf643bacd3ec49
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007, 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 "resource.h"
21 #include "FindBar.h"
22 #include "registry.h"
23 #include <string>
24 #include <Commdlg.h>
26 using namespace std;
28 CFindBar::CFindBar()
29 : m_hParent(NULL)
30 , m_hIcon(NULL)
34 CFindBar::~CFindBar(void)
36 DestroyIcon(m_hIcon);
39 LRESULT CFindBar::DlgFunc(HWND /*hwndDlg*/, UINT uMsg, WPARAM wParam, LPARAM lParam)
41 UNREFERENCED_PARAMETER(lParam);
42 switch (uMsg)
44 case WM_INITDIALOG:
46 m_hIcon = (HICON)::LoadImage(hResource, MAKEINTRESOURCE(IDI_CANCELNORMAL), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
47 SendMessage(GetDlgItem(*this, IDC_FINDEXIT), BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_hIcon);
49 return TRUE;
50 case WM_COMMAND:
51 return DoCommand(LOWORD(wParam), HIWORD(wParam));
52 default:
53 return FALSE;
57 LRESULT CFindBar::DoCommand(int id, int msg)
59 bool bFindPrev = false;
60 switch (id)
62 case IDC_FINDPREV:
63 bFindPrev = true;
64 // fallthrough
65 case IDC_FINDNEXT:
67 DoFind(bFindPrev);
69 break;
70 case IDC_FINDEXIT:
72 ::SendMessage(m_hParent, COMMITMONITOR_FINDEXIT, 0, 0);
74 break;
75 case IDC_FINDTEXT:
77 if (msg == EN_CHANGE)
79 SendMessage(m_hParent, COMMITMONITOR_FINDRESET, 0, 0);
80 DoFind(false);
83 break;
85 return 1;
88 void CFindBar::DoFind(bool bFindPrev)
90 int len = ::GetWindowTextLength(GetDlgItem(*this, IDC_FINDTEXT));
91 TCHAR * findtext = new TCHAR[len+1];
92 ::GetWindowText(GetDlgItem(*this, IDC_FINDTEXT), findtext, len+1);
93 wstring ft = wstring(findtext);
94 delete [] findtext;
95 const bool bCaseSensitive = !!SendMessage(GetDlgItem(*this, IDC_MATCHCASECHECK), BM_GETCHECK, 0, NULL);
96 const UINT message = bFindPrev ? COMMITMONITOR_FINDMSGPREV : COMMITMONITOR_FINDMSGNEXT;
97 ::SendMessage(m_hParent, message, (WPARAM)bCaseSensitive, (LPARAM)ft.c_str());