Leaked source code of windows server 2003
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.

112 lines
2.5 KiB

  1. // Copyright (c) 2000 Microsoft Corporation
  2. //
  3. // multi-line edit box control wrapper
  4. //
  5. // 22 Nov 2000 sburns
  6. //
  7. // added to fix NTRAID#NTBUG9-232092-2000/11/22-sburns
  8. #include "headers.hxx"
  9. #include "MultiLineEditBoxThatForwardsEnterKey.hpp"
  10. MultiLineEditBoxThatForwardsEnterKey::MultiLineEditBoxThatForwardsEnterKey()
  11. {
  12. LOG_CTOR(MultiLineEditBoxThatForwardsEnterKey);
  13. }
  14. MultiLineEditBoxThatForwardsEnterKey::~MultiLineEditBoxThatForwardsEnterKey()
  15. {
  16. LOG_DTOR(MultiLineEditBoxThatForwardsEnterKey);
  17. }
  18. HRESULT
  19. MultiLineEditBoxThatForwardsEnterKey::Init(HWND editControl)
  20. {
  21. LOG_FUNCTION(MultiLineEditBoxThatForwardsEnterKey::Init);
  22. #ifdef DBG
  23. String className = Win::GetClassName(editControl);
  24. ASSERT(className == L"Edit" || className == L"RichEdit20W");
  25. #endif
  26. HRESULT hr = ControlSubclasser::Init(editControl);
  27. return hr;
  28. }
  29. LRESULT
  30. MultiLineEditBoxThatForwardsEnterKey::OnMessage(
  31. UINT message,
  32. WPARAM wparam,
  33. LPARAM lparam)
  34. {
  35. // LOG_FUNCTION(MultiLineEditBoxThatForwardsEnterKey::OnMessage);
  36. switch (message)
  37. {
  38. case WM_KEYDOWN:
  39. {
  40. switch (wparam)
  41. {
  42. case VK_RETURN:
  43. {
  44. // Send the parent window a WM_COMMAND message with IDOK as
  45. // the notification code.
  46. Win::SendMessage(
  47. Win::GetParent(hwnd),
  48. WM_COMMAND,
  49. MAKELONG(::GetDlgCtrlID(hwnd), FORWARDED_ENTER),
  50. reinterpret_cast<LPARAM>(hwnd));
  51. break;
  52. }
  53. default:
  54. {
  55. // do nothing
  56. break;
  57. }
  58. }
  59. break;
  60. }
  61. case EM_SETSEL:
  62. {
  63. // If just so happens that when the control gets focus, it selects
  64. // all of its text. When it does this, instead of passing -1 as
  65. // the LPARAM, it passes 7fffffff. Since we hate that full select
  66. // behavior, and ES_NOHIDESEL doesn't appear to affect it, we detect
  67. // it and snuff the message.
  68. // NTRAID#NTBUG9-498571-2001/11/21-sburns
  69. if ((wparam == 0) && ((int) lparam == 0x7fffffff))
  70. {
  71. // eat the message.
  72. return 0;
  73. }
  74. break;
  75. }
  76. default:
  77. {
  78. // do nothing
  79. break;
  80. }
  81. }
  82. return ControlSubclasser::OnMessage(message, wparam, lparam);
  83. }