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.

162 lines
4.6 KiB

  1. //Copyright (c) 1998 - 1999 Microsoft Corporation
  2. /*******************************************************************************
  3. *
  4. * basedrpe.cpp
  5. *
  6. * implementation of CBaseDropEditBox and CBaseDropEditControl classes
  7. * The CBaseDropEditBox class does things the way we like, overriding the base
  8. * CComboBox (with 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\BASEDRPE.CPP $
  15. *
  16. * Rev 1.1 29 Dec 1995 17:19:16 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 "basedrpe.h"
  27. #ifdef _DEBUG
  28. #undef THIS_FILE
  29. static char BASED_CODE THIS_FILE[] = __FILE__;
  30. #endif
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CBaseDropEdit operations
  33. BOOL
  34. CBaseDropEditControl::Subclass(CComboBox *pWnd)
  35. {
  36. POINT pt;
  37. /*
  38. * Subclass this object to the child window of the specified combo box
  39. * control (the combo box's edit control) and save away the combo box
  40. * object pointer.
  41. */
  42. pt.x = 5;
  43. pt.y = 5;
  44. m_pComboBoxControl = pWnd;
  45. return( SubclassWindow((pWnd->ChildWindowFromPoint(pt))->GetSafeHwnd()) );
  46. } // end CBaseDropEditControl::Subclass
  47. ////////////////////////////////////////////////////////////////////////////////
  48. // CBaseDropEditControl message map
  49. BEGIN_MESSAGE_MAP(CBaseDropEditControl, CEdit)
  50. //{{AFX_MSG_MAP(CBaseDropEditControl)
  51. ON_WM_GETDLGCODE()
  52. ON_WM_CHAR()
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CBaseDropEdit commands
  57. UINT
  58. CBaseDropEditControl::OnGetDlgCode()
  59. {
  60. return( CEdit::OnGetDlgCode() |
  61. (m_pComboBoxControl->GetDroppedState() ? DLGC_WANTALLKEYS : 0) );
  62. } // end CBaseDropEditControl::OnGetDlgCode
  63. void
  64. CBaseDropEditControl::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
  65. {
  66. if ( ((nChar == VK_ESCAPE) || (nChar == VK_RETURN) || (nChar == VK_TAB)) &&
  67. m_pComboBoxControl->GetDroppedState() ) {
  68. m_pComboBoxControl->ShowDropDown(FALSE);
  69. if ( nChar == VK_TAB ) {
  70. /*
  71. * CODEWORK: need to figgure out how to set focus to the next
  72. * or previous control when TAB (or shift-TAB) is pressed while
  73. * we've gobbled up all keys. Here are 3 atempts that don't quite
  74. * do what is needed [remember: the final solution must work for
  75. * both tabbed-dialog as well as regular dialog, in all Windows
  76. * host models (Win31, WinNT, Win95)!]
  77. */
  78. /* Try #1
  79. * Post a TAB WM_KEYDOWN message to the parent (grandparent if parent
  80. * is a property page).
  81. */
  82. // CWnd *pParent = GetParent();
  83. // if ( pParent->IsKindOf(RUNTIME_CLASS(CPropertyPage)) )
  84. // pParent = pParent->GetParent();
  85. //
  86. // pParent->PostMessage( WM_KEYDOWN, (WPARAM)VK_TAB, (LPARAM)0 );
  87. /* Try #2
  88. * Issue a Next or Prev dialog control message to the control's parent,
  89. * based on the state of the shift key.
  90. */
  91. // CDialog *pParent = (CDialog *)GetParent();
  92. // if ( (GetKeyState(VK_SHIFT) < 0) ) {
  93. // pParent->PrevDlgCtrl();
  94. // } else {
  95. // pParent->NextDlgCtrl();
  96. // }
  97. /* Try #3
  98. * Just pass the VK_TAB along to our control.
  99. */
  100. // CEdit::OnChar(nChar, nRepCnt, nFlags);
  101. }
  102. } else {
  103. CEdit::OnChar(nChar, nRepCnt, nFlags);
  104. }
  105. } // end CBaseDropEditControl::OnChar
  106. /////////////////////////////////////////////////////////////////////////////
  107. // CBaseDropEditBox operations
  108. void
  109. CBaseDropEditBox::Subclass(CComboBox *pWnd)
  110. {
  111. /*
  112. * Subclass this object to the specified combo box and let our edit
  113. * object subclass the combo box's edit control.
  114. */
  115. SubclassWindow(pWnd->GetSafeHwnd());
  116. m_EditControl.Subclass(pWnd);
  117. } // end CBaseDropEditBox::Subclass
  118. ////////////////////////////////////////////////////////////////////////////////
  119. // CBaseDropEditBox message map
  120. BEGIN_MESSAGE_MAP(CBaseDropEditBox, CComboBox)
  121. //{{AFX_MSG_MAP(CBaseDropEditBox)
  122. //}}AFX_MSG_MAP
  123. END_MESSAGE_MAP()
  124. /////////////////////////////////////////////////////////////////////////////
  125. // CBaseDropEditBox commands
  126. ////////////////////////////////////////////////////////////////////////////////