Menu

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

Download this file

79 lines (73 with data), 1.7 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
#include "StdAfx.h"
#include "Resource.h"
#include "FindBar.h"
#include "Registry.h"
#include <string>
#include <Commdlg.h>
using namespace std;
CFindBar::CFindBar()
{
}
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));
TCHAR * findtext = new TCHAR[len+1];
::GetWindowText(GetDlgItem(*this, IDC_FINDTEXT), findtext, len+1);
wstring ft = wstring(findtext);
delete [] findtext;
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.