SearchEditBox.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // SearchEditBox.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "cp_main.h"
  5. #include "SearchEditBox.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CSearchEditBox
  13. CSearchEditBox::CSearchEditBox()
  14. {
  15. }
  16. CSearchEditBox::~CSearchEditBox()
  17. {
  18. }
  19. BEGIN_MESSAGE_MAP(CSearchEditBox, CEdit)
  20. //{{AFX_MSG_MAP(CSearchEditBox)
  21. // NOTE - the ClassWizard will add and remove mapping macros here.
  22. //}}AFX_MSG_MAP
  23. END_MESSAGE_MAP()
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CSearchEditBox message handlers
  26. BOOL CSearchEditBox::PreTranslateMessage(MSG* pMsg)
  27. {
  28. switch(pMsg->message)
  29. {
  30. case WM_KEYDOWN:
  31. {
  32. if(pMsg->wParam == VK_RETURN)
  33. {
  34. CWnd *pWnd = GetParent();
  35. if(pWnd)
  36. {
  37. if(g_Opt.m_bFindAsYouType)
  38. {
  39. pWnd->SendMessage(NM_SEARCH_ENTER_PRESSED, 0, 0);
  40. }
  41. else
  42. {
  43. //Send a message to the parent to refill the lb from the search
  44. pWnd->PostMessage(CB_SEARCH, 0, 0);
  45. }
  46. }
  47. return TRUE;
  48. }
  49. else if (pMsg->wParam == VK_DOWN ||
  50. pMsg->wParam == VK_UP ||
  51. pMsg->wParam == VK_F3)
  52. {
  53. if(g_Opt.m_bFindAsYouType)
  54. {
  55. CWnd *pWnd = GetParent();
  56. if(pWnd)
  57. {
  58. pWnd->SendMessage(CB_UPDOWN, pMsg->wParam, pMsg->lParam);
  59. return TRUE;
  60. }
  61. }
  62. }
  63. else if(pMsg->wParam == 'C' && CONTROL_PRESSED ||
  64. pMsg->wParam == 'X' && CONTROL_PRESSED ||
  65. pMsg->wParam == VK_DELETE)
  66. {
  67. LONG lEditSel = GetSel();
  68. if(LOWORD(lEditSel) == HIWORD(lEditSel))
  69. {
  70. CWnd *pWnd = GetParent();
  71. if(pWnd)
  72. {
  73. pWnd->SendMessage(CB_UPDOWN, pMsg->wParam, pMsg->lParam);
  74. return TRUE;
  75. }
  76. }
  77. }
  78. break;
  79. }
  80. }
  81. return CEdit::PreTranslateMessage(pMsg);
  82. }