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.

114 lines
2.9 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2002.
  5. //
  6. // File: FindDlgListCtrl.h
  7. //
  8. // Contents: Implementation for cert find dialog list control
  9. //
  10. //----------------------------------------------------------------------------
  11. // FindDlgListCtrl.cpp : implementation file
  12. //
  13. #include "stdafx.h"
  14. #include <winuser.h>
  15. #include "certmgr.h"
  16. #include "FindDlgListCtrl.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CFindDlgListCtrl
  24. CFindDlgListCtrl::CFindDlgListCtrl() :
  25. m_bSubclassed (false)
  26. {
  27. }
  28. CFindDlgListCtrl::~CFindDlgListCtrl()
  29. {
  30. }
  31. BEGIN_MESSAGE_MAP(CFindDlgListCtrl, CListCtrl)
  32. //{{AFX_MSG_MAP(CFindDlgListCtrl)
  33. ON_WM_DESTROY()
  34. //}}AFX_MSG_MAP
  35. END_MESSAGE_MAP()
  36. /////////////////////////////////////////////////////////////////////////////
  37. // CFindDlgListCtrl message handlers
  38. // Grab the Enter key. Let all others through
  39. LRESULT OnMyGetDlgCode (HWND hWnd, WPARAM /*wParam*/, LPARAM lParam)
  40. {
  41. if ( hWnd )
  42. {
  43. MSG* pMsg = (MSG*)lParam;
  44. if ( pMsg )
  45. {
  46. if ( ( WM_KEYDOWN == pMsg->message ) &&
  47. ( VK_RETURN == LOWORD (pMsg->wParam)) )
  48. {
  49. return DLGC_WANTALLKEYS;
  50. }
  51. }
  52. }
  53. return 0;
  54. }
  55. WNDPROC g_wpOrigEditProc = 0;
  56. // Subclass procedure
  57. LRESULT APIENTRY EditSubclassProc(
  58. HWND hWnd,
  59. UINT uMsg,
  60. WPARAM wParam,
  61. LPARAM lParam)
  62. {
  63. if ( WM_GETDLGCODE == uMsg )
  64. {
  65. LRESULT lResult = OnMyGetDlgCode (hWnd, wParam, lParam);
  66. if ( lResult )
  67. return lResult; // otherwise, call the def proc
  68. }
  69. return ::CallWindowProc (g_wpOrigEditProc, hWnd, uMsg,
  70. wParam, lParam);
  71. }
  72. void CFindDlgListCtrl::OnDestroy()
  73. {
  74. ::SetWindowLongPtr (m_hWnd, GWLP_WNDPROC,
  75. (LONG_PTR) g_wpOrigEditProc);
  76. CListCtrl::OnDestroy();
  77. }
  78. // Subclass the edit control so that we can overload processing for
  79. // WM_GETDLGCODE
  80. // We want to trap this message in the edit control and request all codes when
  81. // the Enter key is pressed and allow default processing at all other times.
  82. LRESULT CFindDlgListCtrl::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
  83. {
  84. if ( 0x1003 == message ) // I can't find a #define for this message
  85. {
  86. if ( m_hWnd && !m_bSubclassed )
  87. {
  88. // Subclass the edit control.
  89. g_wpOrigEditProc = (WNDPROC) ::SetWindowLongPtr (m_hWnd,
  90. GWLP_WNDPROC, reinterpret_cast <LONG_PTR>(EditSubclassProc));
  91. m_bSubclassed = true;
  92. }
  93. }
  94. return CListCtrl::WindowProc(message, wParam, lParam);
  95. }