ctlrefl.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1998 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10. #include "stdafx.h"
  11. #ifdef AFXCTL_CORE2_SEG
  12. #pragma code_seg(AFXCTL_CORE2_SEG)
  13. #endif
  14. #ifdef _DEBUG
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. #define new DEBUG_NEW
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CReflectorWnd
  21. BOOL CReflectorWnd::Create(const CRect& rect, HWND hWndParent)
  22. {
  23. // make sure the default window class is registered
  24. VERIFY(AfxDeferRegisterClass(AFX_WNDOLECONTROL_REG));
  25. return CreateEx(0, AFX_WNDOLECONTROL, NULL,
  26. WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, rect.left, rect.top,
  27. rect.right - rect.left, rect.bottom - rect.top, hWndParent, 0);
  28. }
  29. void CReflectorWnd::PostNcDestroy()
  30. {
  31. if (m_pCtrl != NULL)
  32. m_pCtrl->OnReflectorDestroyed();
  33. delete this;
  34. }
  35. LRESULT CReflectorWnd::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
  36. {
  37. switch (uMsg)
  38. {
  39. case WM_COMMAND:
  40. case WM_NOTIFY:
  41. case WM_CTLCOLORBTN:
  42. case WM_CTLCOLORDLG:
  43. case WM_CTLCOLOREDIT:
  44. case WM_CTLCOLORLISTBOX:
  45. case WM_CTLCOLORMSGBOX:
  46. case WM_CTLCOLORSCROLLBAR:
  47. case WM_CTLCOLORSTATIC:
  48. case WM_DRAWITEM:
  49. case WM_MEASUREITEM:
  50. case WM_DELETEITEM:
  51. case WM_VKEYTOITEM:
  52. case WM_CHARTOITEM:
  53. case WM_COMPAREITEM:
  54. case WM_HSCROLL:
  55. case WM_VSCROLL:
  56. case WM_PARENTNOTIFY:
  57. if (m_pCtrl != NULL)
  58. return m_pCtrl->SendMessage(OCM__BASE + uMsg, wParam, lParam);
  59. break;
  60. case WM_SETFOCUS:
  61. if (m_pCtrl != NULL)
  62. {
  63. m_pCtrl->SetFocus();
  64. return 0;
  65. }
  66. break;
  67. }
  68. return CWnd::WindowProc(uMsg, wParam, lParam);
  69. }
  70. void CReflectorWnd::SetControl(COleControl* pCtrl)
  71. {
  72. m_pCtrl = pCtrl;
  73. }
  74. LRESULT CParkingWnd::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
  75. {
  76. HWND hWndSource = NULL;
  77. switch (uMsg)
  78. {
  79. case WM_COMMAND:
  80. case WM_CTLCOLORBTN:
  81. case WM_CTLCOLORDLG:
  82. case WM_CTLCOLOREDIT:
  83. case WM_CTLCOLORLISTBOX:
  84. case WM_CTLCOLORMSGBOX:
  85. case WM_CTLCOLORSCROLLBAR:
  86. case WM_CTLCOLORSTATIC:
  87. case WM_VKEYTOITEM:
  88. case WM_CHARTOITEM:
  89. case WM_HSCROLL:
  90. case WM_VSCROLL:
  91. hWndSource = (HWND)lParam;
  92. break;
  93. case WM_NOTIFY:
  94. hWndSource = ((NMHDR*)lParam)->hwndFrom;
  95. break;
  96. case WM_DRAWITEM:
  97. hWndSource = ((DRAWITEMSTRUCT*)lParam)->hwndItem;
  98. break;
  99. case WM_MEASUREITEM:
  100. m_idMap.Lookup((void*)(DWORD)HIWORD(wParam), (void*&)hWndSource);
  101. break;
  102. case WM_DELETEITEM:
  103. hWndSource = ((DELETEITEMSTRUCT*)lParam)->hwndItem;
  104. break;
  105. case WM_COMPAREITEM:
  106. hWndSource = ((COMPAREITEMSTRUCT*)lParam)->hwndItem;
  107. break;
  108. case WM_PARENTNOTIFY:
  109. switch (LOWORD(wParam))
  110. {
  111. case WM_CREATE:
  112. m_idMap.SetAt((void*)(DWORD)HIWORD(wParam), (HWND)lParam);
  113. hWndSource = (HWND)lParam;
  114. break;
  115. case WM_DESTROY:
  116. m_idMap.RemoveKey((void*)(DWORD)HIWORD(wParam));
  117. hWndSource = (HWND)lParam;
  118. break;
  119. default:
  120. m_idMap.Lookup((void*)(DWORD)HIWORD(wParam), (void*&)hWndSource);
  121. break;
  122. }
  123. }
  124. if (hWndSource != NULL)
  125. return ::SendMessage(hWndSource, OCM__BASE + uMsg, wParam, lParam);
  126. else
  127. return CWnd::WindowProc(uMsg, wParam, lParam);
  128. }
  129. /////////////////////////////////////////////////////////////////////////////
  130. // Force any extra compiler-generated code into AFX_INIT_SEG
  131. #ifdef AFX_INIT_SEG
  132. #pragma code_seg(AFX_INIT_SEG)
  133. #endif