Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // searchbx.cpp : implementation file
  9. #include "stdafx.h"
  10. #include "hammer.h"
  11. #include "searchbox.h"
  12. #ifdef _DEBUG
  13. #undef THIS_FILE
  14. static char BASED_CODE THIS_FILE[] = __FILE__;
  15. #endif
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CSearchBox
  18. CSearchBox::CSearchBox()
  19. {
  20. }
  21. CSearchBox::~CSearchBox()
  22. {
  23. }
  24. BEGIN_MESSAGE_MAP(CSearchBox, CComboBox)
  25. //{{AFX_MSG_MAP(CSearchBox)
  26. // NOTE - the ClassWizard will add and remove mapping macros here.
  27. //}}AFX_MSG_MAP
  28. END_MESSAGE_MAP()
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CSearchBox message handlers
  31. BOOL CSearchBox::PreTranslateMessage(MSG* pMsg)
  32. {
  33. if ((pMsg->message != WM_KEYDOWN) || (pMsg->wParam != VK_RETURN))
  34. return CComboBox::PreTranslateMessage(pMsg);
  35. // when the enter key is hit in the ComboBox we want to add the string
  36. // to the top of the list and hilight it. We also want to limit the
  37. // list to the last 15 entries.
  38. if ((pMsg->lParam & 0x40000000) == 0) // Not a repeat.
  39. {
  40. CString strText;
  41. GetWindowText(strText);
  42. InsertString(0, strText);
  43. SetCurSel(0);
  44. if (GetCount() > 15)
  45. DeleteString(GetCount()-1);
  46. }
  47. return TRUE;
  48. }