home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / MS_VC.50 / VC / MFC / SRC / CTLREFL.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-30  |  3.8 KB  |  165 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1997 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.  
  11. #include "stdafx.h"
  12.  
  13. #ifdef AFXCTL_CORE2_SEG
  14. #pragma code_seg(AFXCTL_CORE2_SEG)
  15. #endif
  16.  
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[] = __FILE__;
  20. #endif
  21.  
  22. #define new DEBUG_NEW
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CReflectorWnd
  26.  
  27. BOOL CReflectorWnd::Create(const CRect& rect, HWND hWndParent)
  28. {
  29.     // make sure the default window class is registered
  30.     if (!AfxDeferRegisterClass(AFX_WNDOLECONTROL_REG))
  31.         return FALSE;
  32.  
  33.     return CreateEx(0, AFX_WNDOLECONTROL, NULL,
  34.         WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS, rect.left, rect.top,
  35.         rect.right - rect.left, rect.bottom - rect.top, hWndParent, 0);
  36. }
  37.  
  38. void CReflectorWnd::PostNcDestroy()
  39. {
  40.     if (m_pCtrl != NULL)
  41.         m_pCtrl->OnReflectorDestroyed();
  42.     delete this;
  43. }
  44.  
  45. LRESULT CReflectorWnd::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
  46. {
  47.     switch (uMsg)
  48.     {
  49.     case WM_COMMAND:
  50.     case WM_NOTIFY:
  51.     case WM_CTLCOLORBTN:
  52.     case WM_CTLCOLORDLG:
  53.     case WM_CTLCOLOREDIT:
  54.     case WM_CTLCOLORLISTBOX:
  55.     case WM_CTLCOLORMSGBOX:
  56.     case WM_CTLCOLORSCROLLBAR:
  57.     case WM_CTLCOLORSTATIC:
  58.     case WM_DRAWITEM:
  59.     case WM_MEASUREITEM:
  60.     case WM_DELETEITEM:
  61.     case WM_VKEYTOITEM:
  62.     case WM_CHARTOITEM:
  63.     case WM_COMPAREITEM:
  64.     case WM_HSCROLL:
  65.     case WM_VSCROLL:
  66.     case WM_PARENTNOTIFY:
  67.         if (m_pCtrl != NULL)
  68.             return m_pCtrl->SendMessage(OCM__BASE + uMsg, wParam, lParam);
  69.         break;
  70.  
  71.     case WM_SETFOCUS:
  72.         if (m_pCtrl != NULL)
  73.         {
  74.             m_pCtrl->SetFocus();
  75.             return 0;
  76.         }
  77.         break;
  78.  
  79.     case WM_SIZE:
  80.         if (m_pCtrl != NULL)
  81.             m_pCtrl->MoveWindow(0, 0, LOWORD(lParam), HIWORD(lParam));
  82.         break;
  83.     }
  84.  
  85.     return CWnd::WindowProc(uMsg, wParam, lParam);
  86. }
  87.  
  88. void CReflectorWnd::SetControl(COleControl* pCtrl)
  89. {
  90.     m_pCtrl = pCtrl;
  91. }
  92.  
  93. LRESULT CParkingWnd::WindowProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
  94. {
  95.     HWND hWndSource = NULL;
  96.  
  97.     switch (uMsg)
  98.     {
  99.     case WM_COMMAND:
  100.     case WM_CTLCOLORBTN:
  101.     case WM_CTLCOLORDLG:
  102.     case WM_CTLCOLOREDIT:
  103.     case WM_CTLCOLORLISTBOX:
  104.     case WM_CTLCOLORMSGBOX:
  105.     case WM_CTLCOLORSCROLLBAR:
  106.     case WM_CTLCOLORSTATIC:
  107.     case WM_VKEYTOITEM:
  108.     case WM_CHARTOITEM:
  109.     case WM_HSCROLL:
  110.     case WM_VSCROLL:
  111.         hWndSource = (HWND)lParam;
  112.         break;
  113.  
  114.     case WM_NOTIFY:
  115.         hWndSource = ((NMHDR*)lParam)->hwndFrom;
  116.         break;
  117.  
  118.     case WM_DRAWITEM:
  119.         hWndSource = ((DRAWITEMSTRUCT*)lParam)->hwndItem;
  120.         break;
  121.  
  122.     case WM_MEASUREITEM:
  123.         m_idMap.Lookup((void*)(DWORD)HIWORD(wParam), (void*&)hWndSource);
  124.         break;
  125.  
  126.     case WM_DELETEITEM:
  127.         hWndSource = ((DELETEITEMSTRUCT*)lParam)->hwndItem;
  128.         break;
  129.  
  130.     case WM_COMPAREITEM:
  131.         hWndSource = ((COMPAREITEMSTRUCT*)lParam)->hwndItem;
  132.         break;
  133.  
  134.     case WM_PARENTNOTIFY:
  135.         switch (LOWORD(wParam))
  136.         {
  137.         case WM_CREATE:
  138.             m_idMap.SetAt((void*)(DWORD)HIWORD(wParam), (HWND)lParam);
  139.             hWndSource = (HWND)lParam;
  140.             break;
  141.  
  142.         case WM_DESTROY:
  143.             m_idMap.RemoveKey((void*)(DWORD)HIWORD(wParam));
  144.             hWndSource = (HWND)lParam;
  145.             break;
  146.  
  147.         default:
  148.             m_idMap.Lookup((void*)(DWORD)HIWORD(wParam), (void*&)hWndSource);
  149.             break;
  150.         }
  151.     }
  152.  
  153.     if (hWndSource != NULL)
  154.         return ::SendMessage(hWndSource, OCM__BASE + uMsg, wParam, lParam);
  155.     else
  156.         return CWnd::WindowProc(uMsg, wParam, lParam);
  157. }
  158.  
  159. /////////////////////////////////////////////////////////////////////////////
  160. // Force any extra compiler-generated code into AFX_INIT_SEG
  161.  
  162. #ifdef AFX_INIT_SEG
  163. #pragma code_seg(AFX_INIT_SEG)
  164. #endif
  165.