summaryrefslogtreecommitdiff
path: root/hammer/searchbox.cpp
blob: 881337adb788abfa5bb42530cc7826b2eb33755c (plain) (blame)
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//
//=============================================================================//
// searchbx.cpp : implementation file

#include "stdafx.h"
#include "hammer.h"
#include "searchbox.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSearchBox

CSearchBox::CSearchBox()
{
}

CSearchBox::~CSearchBox()
{
}

BEGIN_MESSAGE_MAP(CSearchBox, CComboBox)
	//{{AFX_MSG_MAP(CSearchBox)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSearchBox message handlers

BOOL CSearchBox::PreTranslateMessage(MSG* pMsg)
{
	if ((pMsg->message != WM_KEYDOWN) || (pMsg->wParam != VK_RETURN))
		return CComboBox::PreTranslateMessage(pMsg);

	// when the enter key is hit in the ComboBox we want to add the string
	// to the top of the list and hilight it.  We also want to limit the
	// list to the last 15 entries.
	if ((pMsg->lParam & 0x40000000) == 0)   // Not a repeat.
	{
		CString strText;
		GetWindowText(strText);
		InsertString(0, strText);
		SetCurSel(0);
		if (GetCount() > 15)
			DeleteString(GetCount()-1);
	}
	return TRUE;
}