renamed ITEMIS_SUBMODULE to ITEMIS_SUBMODULECONTAINER
[TortoiseGit.git] / src / TortoiseUDiff / FindBar.cpp
blob8b99248a137fbf74ac768f67d189755c60b1ea24
1 // TortoiseSVN - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2007 - Stefan Kueng
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()
32 CFindBar::~CFindBar(void)
34 DestroyIcon(m_hIcon);
37 LRESULT CFindBar::DlgFunc(HWND /*hwndDlg*/, UINT uMsg, WPARAM wParam, LPARAM lParam)
39 UNREFERENCED_PARAMETER(lParam);
40 switch (uMsg)
42 case WM_INITDIALOG:
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);
47 return TRUE;
48 case WM_COMMAND:
49 return DoCommand(LOWORD(wParam), HIWORD(wParam));
50 default:
51 return FALSE;
55 LRESULT CFindBar::DoCommand(int id, int msg)
57 bool bFindPrev = false;
58 switch (id)
60 case IDC_FINDPREV:
61 bFindPrev = true;
62 case IDC_FINDNEXT:
64 DoFind(bFindPrev);
66 break;
67 case IDC_FINDEXIT:
69 ::SendMessage(m_hParent, COMMITMONITOR_FINDEXIT, 0, 0);
71 break;
72 case IDC_FINDTEXT:
74 if (msg == EN_CHANGE)
76 SendMessage(m_hParent, COMMITMONITOR_FINDRESET, 0, 0);
77 DoFind(false);
80 break;
82 return 1;
85 void CFindBar::DoFind(bool bFindPrev)
87 int len = ::GetWindowTextLength(GetDlgItem(*this, IDC_FINDTEXT));
88 TCHAR * findtext = new TCHAR[len+1];
89 ::GetWindowText(GetDlgItem(*this, IDC_FINDTEXT), findtext, len+1);
90 wstring ft = wstring(findtext);
91 delete [] findtext;
92 bool bCaseSensitive = !!SendMessage(GetDlgItem(*this, IDC_MATCHCASECHECK), BM_GETCHECK, 0, NULL);
93 if (bFindPrev)
94 ::SendMessage(m_hParent, COMMITMONITOR_FINDMSGPREV, (WPARAM)bCaseSensitive, (LPARAM)ft.c_str());
95 else
96 ::SendMessage(m_hParent, COMMITMONITOR_FINDMSGNEXT, (WPARAM)bCaseSensitive, (LPARAM)ft.c_str());