Menu

[r1075]: / trunk / src / FindBar.cpp  Maximize  Restore  History

Download this file

100 lines (88 with data), 2.8 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// CommitMonitor - simple checker for new commits in svn repositories
// Copyright (C) 2007, 2012 - Stefan Kueng
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
#include "stdafx.h"
#include "resource.h"
#include "FindBar.h"
#include "Registry.h"
#include <string>
#include <Commdlg.h>
#include <memory>
CFindBar::CFindBar()
: m_hParent(NULL)
, m_hBmp(NULL)
{
}
CFindBar::~CFindBar(void)
{
DeleteObject(m_hBmp);
}
LRESULT CFindBar::DlgFunc(HWND /*hwndDlg*/, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
UNREFERENCED_PARAMETER(lParam);
switch (uMsg)
{
case WM_INITDIALOG:
{
m_hBmp = ::LoadBitmap(hResource, MAKEINTRESOURCE(IDB_CANCELNORMAL));
SendMessage(GetDlgItem(*this, IDC_FINDEXIT), BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)m_hBmp);
}
return TRUE;
case WM_COMMAND:
return DoCommand(LOWORD(wParam), HIWORD(wParam));
default:
return FALSE;
}
}
LRESULT CFindBar::DoCommand(int id, int msg)
{
bool bFindPrev = false;
switch (id)
{
case IDC_FINDPREV:
bFindPrev = true;
case IDC_FINDNEXT:
{
DoFind(bFindPrev);
}
break;
case IDC_FINDEXIT:
{
::SendMessage(m_hParent, COMMITMONITOR_FINDEXIT, 0, 0);
}
break;
case IDC_FINDTEXT:
{
if (msg == EN_CHANGE)
{
SendMessage(m_hParent, COMMITMONITOR_FINDRESET, 0, 0);
DoFind(false);
}
}
break;
}
return 1;
}
void CFindBar::DoFind(bool bFindPrev)
{
int len = ::GetWindowTextLength(GetDlgItem(*this, IDC_FINDTEXT));
std::unique_ptr<TCHAR[]> findtext(new TCHAR[len+1]);
::GetDlgItemText(*this, IDC_FINDTEXT, findtext.get(), len+1);
std::wstring ft = std::wstring(findtext.get());
bool bCaseSensitive = !!SendMessage(GetDlgItem(*this, IDC_MATCHCASECHECK), BM_GETCHECK, 0, NULL);
if (bFindPrev)
::SendMessage(m_hParent, COMMITMONITOR_FINDMSGPREV, (WPARAM)bCaseSensitive, (LPARAM)ft.c_str());
else
::SendMessage(m_hParent, COMMITMONITOR_FINDMSGNEXT, (WPARAM)bCaseSensitive, (LPARAM)ft.c_str());
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.