summaryrefslogtreecommitdiff
path: root/hammer/searchbox.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /hammer/searchbox.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'hammer/searchbox.cpp')
-rw-r--r--hammer/searchbox.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/hammer/searchbox.cpp b/hammer/searchbox.cpp
new file mode 100644
index 0000000..881337a
--- /dev/null
+++ b/hammer/searchbox.cpp
@@ -0,0 +1,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;
+}