OSDN Git Service

Fix when setting ssh client is null. GIT_SSH environment variable is not clear
[tortoisegit/TortoiseGitJp.git] / src / TortoiseUDiff / FindBar.cpp
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2007 - Stefan Kueng\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #include "StdAfx.h"\r
20 #include "Resource.h"\r
21 #include "FindBar.h"\r
22 #include "Registry.h"\r
23 #include <string>\r
24 #include <Commdlg.h>\r
25 \r
26 using namespace std;\r
27 \r
28 CFindBar::CFindBar()\r
29 {\r
30 }\r
31 \r
32 CFindBar::~CFindBar(void)\r
33 {\r
34         DestroyIcon(m_hIcon);\r
35 }\r
36 \r
37 LRESULT CFindBar::DlgFunc(HWND /*hwndDlg*/, UINT uMsg, WPARAM wParam, LPARAM lParam)\r
38 {\r
39         UNREFERENCED_PARAMETER(lParam);\r
40         switch (uMsg)\r
41         {\r
42         case WM_INITDIALOG:\r
43                 {\r
44                         m_hIcon = (HICON)::LoadImage(hResource, MAKEINTRESOURCE(IDI_CANCELNORMAL), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);\r
45                         SendMessage(GetDlgItem(*this, IDC_FINDEXIT), BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_hIcon);\r
46                 }\r
47                 return TRUE;\r
48         case WM_COMMAND:\r
49                 return DoCommand(LOWORD(wParam), HIWORD(wParam));\r
50         default:\r
51                 return FALSE;\r
52         }\r
53 }\r
54 \r
55 LRESULT CFindBar::DoCommand(int id, int msg)\r
56 {\r
57     bool bFindPrev = false;\r
58         switch (id)\r
59         {\r
60     case IDC_FINDPREV:\r
61         bFindPrev = true;\r
62     case IDC_FINDNEXT:\r
63         {\r
64                         DoFind(bFindPrev);\r
65         }\r
66         break;\r
67         case IDC_FINDEXIT:\r
68                 {\r
69                         ::SendMessage(m_hParent, COMMITMONITOR_FINDEXIT, 0, 0);\r
70                 }\r
71                 break;\r
72         case IDC_FINDTEXT:\r
73                 {\r
74                         if (msg == EN_CHANGE)\r
75                         {\r
76                                 SendMessage(m_hParent, COMMITMONITOR_FINDRESET, 0, 0);\r
77                                 DoFind(false);\r
78                         }\r
79                 }\r
80                 break;\r
81         }\r
82         return 1;\r
83 }\r
84 \r
85 void CFindBar::DoFind(bool bFindPrev)\r
86 {\r
87         int len = ::GetWindowTextLength(GetDlgItem(*this, IDC_FINDTEXT));\r
88         TCHAR * findtext = new TCHAR[len+1];\r
89         ::GetWindowText(GetDlgItem(*this, IDC_FINDTEXT), findtext, len+1);\r
90         wstring ft = wstring(findtext);\r
91         delete [] findtext;\r
92         bool bCaseSensitive = !!SendMessage(GetDlgItem(*this, IDC_MATCHCASECHECK), BM_GETCHECK, 0, NULL);\r
93         if (bFindPrev)\r
94                 ::SendMessage(m_hParent, COMMITMONITOR_FINDMSGPREV, (WPARAM)bCaseSensitive, (LPARAM)ft.c_str());\r
95         else\r
96                 ::SendMessage(m_hParent, COMMITMONITOR_FINDMSGNEXT, (WPARAM)bCaseSensitive, (LPARAM)ft.c_str());\r
97 }