Source code of Windows XP (NT5)
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.

122 lines
3.5 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. /*******************************************************************************
  3. *
  4. * basedrpl.cpp
  5. *
  6. * implementation of CBaseDropListBox class
  7. * The CBaseDropListBox class does things the way we like, overriding the base
  8. * CComboBox (no edit field) class.
  9. *
  10. * copyright notice: Copyright 1995, Citrix Systems Inc.
  11. *
  12. * $Author: butchd $ Butch Davis
  13. *
  14. * $Log: N:\NT\PRIVATE\UTILS\CITRIX\WINUTILS\COMMON\VCS\BASEDRPL.CPP $
  15. *
  16. * Rev 1.1 29 Dec 1995 17:19:26 butchd
  17. * update
  18. *
  19. *******************************************************************************/
  20. /*
  21. * include files
  22. */
  23. #include <stdafx.h>
  24. #include <afxwin.h> // MFC core and standard components
  25. #include <afxext.h> // MFC extensions
  26. #include "basedrpl.h"
  27. #ifdef _DEBUG
  28. #undef THIS_FILE
  29. static char BASED_CODE THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CBaseDropListBox operations
  33. BOOL
  34. CBaseDropListBox::Subclass(CComboBox *pWnd)
  35. {
  36. return( SubclassWindow(pWnd->GetSafeHwnd()) );
  37. } // end CBaseDropListBox::Subclass
  38. ////////////////////////////////////////////////////////////////////////////////
  39. // CBaseDropListBox message map
  40. BEGIN_MESSAGE_MAP(CBaseDropListBox, CComboBox)
  41. //{{AFX_MSG_MAP(CBaseDropListBox)
  42. ON_WM_GETDLGCODE()
  43. ON_WM_CHAR()
  44. //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CBaseDropListBox commands
  48. UINT
  49. CBaseDropListBox::OnGetDlgCode()
  50. {
  51. return( CComboBox::OnGetDlgCode() |
  52. (GetDroppedState() ? DLGC_WANTALLKEYS : 0) );
  53. } // end CBaseDropListBox::OnGetDlgCode
  54. void
  55. CBaseDropListBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
  56. {
  57. if ( ((nChar == VK_ESCAPE) || (nChar == VK_RETURN) || (nChar == VK_TAB)) &&
  58. GetDroppedState() ) {
  59. ShowDropDown(FALSE);
  60. if ( nChar == VK_TAB ) {
  61. /*
  62. * CODEWORK: need to figgure out how to set focus to the next
  63. * or previous control when TAB (or shift-TAB) is pressed while
  64. * we've gobbled up all keys. Here are 3 atempts that don't quite
  65. * do what is needed [remember: the final solution must work for
  66. * both tabbed-dialog as well as regular dialog, in all Windows
  67. * host models (Win31, WinNT, Win95)!]
  68. */
  69. /* Try #1
  70. * Post a TAB WM_KEYDOWN message to the parent (grandparent if parent
  71. * is a property page).
  72. */
  73. // CWnd *pParent = GetParent();
  74. // if ( pParent->IsKindOf(RUNTIME_CLASS(CPropertyPage)) )
  75. // pParent = pParent->GetParent();
  76. //
  77. // pParent->PostMessage( WM_KEYDOWN, (WPARAM)VK_TAB, (LPARAM)0 );
  78. /* Try #2
  79. * Issue a Next or Prev dialog control message to the control's parent,
  80. * based on the state of the shift key.
  81. */
  82. // CDialog *pParent = (CDialog *)GetParent();
  83. // if ( (GetKeyState(VK_SHIFT) < 0) ) {
  84. // pParent->PrevDlgCtrl();
  85. // } else {
  86. // pParent->NextDlgCtrl();
  87. // }
  88. /* Try #3
  89. * Just pass the VK_TAB along to our control.
  90. */
  91. // CComboBox::OnChar(nChar, nRepCnt, nFlags);
  92. }
  93. } else {
  94. CComboBox::OnChar(nChar, nRepCnt, nFlags);
  95. }
  96. } // end CBaseDropListBox::OnChar
  97. ////////////////////////////////////////////////////////////////////////////////