home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / mfc / src / ctlinplc.cpp < prev    next >
C/C++ Source or Header  |  1998-06-16  |  16KB  |  643 lines

  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.  
  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. struct _AFXCTL_UIACTIVE_INFO
  25. {
  26.     OLEMENUGROUPWIDTHS m_menuWidths;
  27.     HMENU m_hSharedMenu;
  28.     HOLEMENU m_hOleMenu;
  29.  
  30.     _AFXCTL_UIACTIVE_INFO(HMENU hInPlaceMenu, LPOLEINPLACEFRAME pInPlaceFrame);
  31.     ~_AFXCTL_UIACTIVE_INFO();
  32. };
  33.  
  34. _AFXCTL_UIACTIVE_INFO::_AFXCTL_UIACTIVE_INFO(HMENU hInPlaceMenu,
  35.     LPOLEINPLACEFRAME pInPlaceFrame)
  36. {
  37.     memset(&m_menuWidths, 0, sizeof m_menuWidths);
  38.     m_hSharedMenu = NULL;
  39.     m_hOleMenu = NULL;
  40.  
  41.     if (hInPlaceMenu != NULL)
  42.     {
  43.         // Create shared menu
  44.         if ((m_hSharedMenu = ::CreateMenu()) == NULL)
  45.             return;
  46.  
  47.         // Start out by getting menu from container
  48.         if (pInPlaceFrame->InsertMenus(m_hSharedMenu, &m_menuWidths) != S_OK)
  49.         {
  50.             ::DestroyMenu(m_hSharedMenu);
  51.             m_hSharedMenu = NULL;
  52.         }
  53.         else
  54.         {
  55.             // Container shouldn't touch these
  56.             ASSERT(m_menuWidths.width[1] == 0);
  57.             ASSERT(m_menuWidths.width[3] == 0);
  58.             ASSERT(m_menuWidths.width[5] == 0);
  59.  
  60.             // Only copy the popups if there is a menu loaded
  61.             if (hInPlaceMenu != NULL)
  62.             {
  63.                 // Insert our menu popups amongst the container menus
  64.                 AfxMergeMenus(m_hSharedMenu, hInPlaceMenu,
  65.                     &m_menuWidths.width[0], 1);
  66.             }
  67.         }
  68.     }
  69.  
  70.     // Finally create the special OLE menu descriptor
  71.     m_hOleMenu = ::OleCreateMenuDescriptor(m_hSharedMenu, &m_menuWidths);
  72. }
  73.  
  74. _AFXCTL_UIACTIVE_INFO::~_AFXCTL_UIACTIVE_INFO()
  75. {
  76.     if (m_hSharedMenu != NULL)
  77.         ::DestroyMenu(m_hSharedMenu);
  78.  
  79.     if (m_hOleMenu != NULL)
  80.         VERIFY(::OleDestroyMenuDescriptor(m_hOleMenu) == S_OK);
  81. }
  82.  
  83. short AFXAPI _AfxShiftState();
  84.  
  85. void AFXAPI _GetClippingCoordinates(LPCRECT pPosRect, LPCRECT pClipRect,
  86.     LPRECT pIntersectRect, LPPOINT pOffsetPoint)
  87. {
  88.     int clipLeft = 0;
  89.     int clipTop = 0;
  90.  
  91.     if ((pClipRect == NULL) || IsRectEmpty(pClipRect))
  92.     {
  93.         CopyRect(pIntersectRect, pPosRect);
  94.     }
  95.     else
  96.     {
  97.         IntersectRect(pIntersectRect, pPosRect, pClipRect);
  98.         clipLeft = pClipRect->left;
  99.         clipTop = pClipRect->top;
  100.     }
  101.  
  102.     pOffsetPoint->x = min(0, pPosRect->left - clipLeft);
  103.     pOffsetPoint->y = min(0, pPosRect->top - clipTop);
  104. }
  105.  
  106. HRESULT COleControl::OnActivateInPlace(BOOL bUIActivate, LPMSG pMsg)
  107. {
  108. #ifdef _AFXDLL
  109.     if (m_bOpen)
  110.     {
  111.         m_pWndOpenFrame->SetActiveWindow();
  112.         SendAdvise(OBJECTCODE_SHOWWINDOW);
  113.         return S_OK;
  114.     }
  115. #endif
  116.  
  117.     // Initialize pointer to in-place site, if necessary.
  118.     if (m_pInPlaceSite == NULL)
  119.     {
  120.         if (m_pClientSite == NULL)
  121.             return E_UNEXPECTED;
  122.  
  123.         if ((GetControlFlags() & windowlessActivate) &&
  124.             SUCCEEDED(m_pClientSite->QueryInterface(IID_IOleInPlaceSiteWindowless,
  125.             reinterpret_cast<void**>(&m_pInPlaceSiteWndless))))
  126.         {
  127.             m_bInPlaceSiteWndless = m_bInPlaceSiteEx = TRUE;
  128.         }
  129.         else if ((GetControlFlags() & noFlickerActivate) &&
  130.             SUCCEEDED(m_pClientSite->QueryInterface(IID_IOleInPlaceSiteEx,
  131.             reinterpret_cast<void**>(&m_pInPlaceSiteEx))))
  132.         {
  133.             m_bInPlaceSiteEx = TRUE;
  134.         }
  135.         else if (SUCCEEDED(m_pClientSite->QueryInterface(IID_IOleInPlaceSite,
  136.             reinterpret_cast<void**>(&m_pInPlaceSite))))
  137.         {
  138.             m_bInPlaceSiteEx = FALSE;
  139.         }
  140.         else
  141.         {
  142.             m_pInPlaceSite = NULL;
  143.             return E_FAIL;
  144.         }
  145.     }
  146.  
  147.     ASSERT(m_pInPlaceSite != NULL);
  148.  
  149.     if ((m_bInPlaceActive && !bUIActivate) || m_bUIActive)
  150.     {
  151.         CWnd* pWndOuter = GetOuterWindow();
  152.         HWND hwndParent;
  153.         if ((pWndOuter != NULL) &&
  154.             SUCCEEDED(m_pInPlaceSite->GetWindow(&hwndParent)) &&
  155.             (hwndParent == ::GetParent(pWndOuter->m_hWnd)))
  156.         {
  157.             ::SetWindowPos(pWndOuter->m_hWnd, NULL, 0, 0, 0, 0,
  158.                 SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE|
  159.                 SWP_SHOWWINDOW);
  160.             OnSetObjectRects(m_rcPos, NULL);
  161.             return S_OK;
  162.         }
  163.     }
  164.  
  165.     // Check if container allows windowless activation.
  166.     if (m_bInPlaceSiteWndless)
  167.     {
  168.         if (m_pInPlaceSiteWndless->CanWindowlessActivate() != S_OK)
  169.             m_bInPlaceSiteWndless = FALSE;
  170.     }
  171.  
  172.     HRESULT hr = E_FAIL;
  173.     if (m_pInPlaceSite != NULL)
  174.         hr = m_pInPlaceSite->CanInPlaceActivate();
  175.  
  176.     if (hr != NOERROR)
  177.     {
  178.         // Site doesn't allow in-place activation.
  179.         return OnOpen(FALSE, pMsg);
  180.     }
  181.  
  182.     if (!m_bInPlaceActive)
  183.     {
  184.         if (m_bInPlaceSiteEx)
  185.         {
  186.             // flicker-free and/or windowless activation
  187.             BOOL bNoRedraw;
  188.             m_pInPlaceSiteEx->OnInPlaceActivateEx(&bNoRedraw,
  189.                 m_bInPlaceSiteWndless ? ACTIVATE_WINDOWLESS : 0);
  190.             if (GetControlFlags() & noFlickerActivate)
  191.                 m_bNoRedraw = bNoRedraw;
  192.         }
  193.         else
  194.         {
  195.             // old-style activation
  196.             m_pInPlaceSite->OnInPlaceActivate();
  197.         }
  198.     }
  199.  
  200.     HWND hwndParent = NULL;
  201.  
  202.     if (SUCCEEDED(m_pInPlaceSite->GetWindow(&hwndParent)))
  203.     {
  204.         CRect rcClip;
  205.         m_frameInfo.cb = sizeof(OLEINPLACEFRAMEINFO);
  206.  
  207.         RELEASE(m_pInPlaceFrame);
  208.         RELEASE(m_pInPlaceDoc);
  209.  
  210.         if (SUCCEEDED(m_pInPlaceSite->GetWindowContext(
  211.                         &m_pInPlaceFrame, &m_pInPlaceDoc,
  212.                         &m_rcPos, &rcClip, &m_frameInfo)))
  213.         {
  214.             ASSERT(m_pInPlaceFrame != NULL);
  215.  
  216.             CRect rectClip;
  217.             if (!m_bInPlaceSiteWndless)
  218.             {
  219.                 _GetClippingCoordinates(&m_rcPos, &rcClip, rectClip,
  220.                     &m_ptOffset);
  221.                 m_bInPlaceActive = CreateControlWindow(hwndParent, m_rcPos,
  222.                     rectClip);
  223.             }
  224.             else
  225.             {
  226.                 m_bInPlaceActive = TRUE;
  227.             }
  228.  
  229.             if (m_bInPlaceActive)
  230.             {
  231.                 if (bUIActivate)
  232.                 {
  233.                     if (m_bInPlaceSiteEx)
  234.                     {
  235.                         if (m_pInPlaceSiteEx->RequestUIActivate() != S_OK)
  236.                             m_pInPlaceSite->OnUIDeactivate(FALSE);
  237.                     }
  238.  
  239.                     BuildSharedMenu();
  240.  
  241.                     m_bUIActive = TRUE;
  242.                     m_pInPlaceSite->OnUIActivate();
  243.  
  244.                     m_pInPlaceFrame->SetActiveObject(
  245.                         &m_xOleInPlaceActiveObject, NULL);
  246.                     if (m_pInPlaceDoc != NULL)
  247.                         m_pInPlaceDoc->SetActiveObject(
  248.                             &m_xOleInPlaceActiveObject, NULL);
  249.  
  250.                     if (m_hWnd != NULL)
  251.                     {
  252.                         BOOL bHandles = AmbientShowGrabHandles();
  253.                         BOOL bHatching = AmbientShowHatching();
  254.  
  255.                         if (bHandles || bHatching)
  256.                             CreateTracker(bHandles, bHatching, rcClip);
  257.                     }
  258.  
  259.                     AddFrameLevelUI();
  260.  
  261.                     if (bUIActivate != -1 &&
  262.                         (m_hWnd != NULL) && !IsChild(GetFocus()))
  263.                     {
  264.                         SetFocus();
  265.                     }
  266.                 }
  267.  
  268.                 // Pass thru the window message that caused us to be activated
  269.                 if ((m_hWnd != NULL || m_bInPlaceSiteWndless) && (pMsg != NULL))
  270.                     ForwardActivationMsg(pMsg);
  271.  
  272.                 // Send appropriate notifications...
  273.                 SendAdvise(OBJECTCODE_SHOWOBJECT);
  274.  
  275.                 return S_OK;
  276.             }
  277.         }
  278.     }
  279.  
  280.     RELEASE(m_pInPlaceFrame);
  281.     RELEASE(m_pInPlaceDoc);
  282.  
  283.     return E_FAIL;
  284. }
  285.  
  286. void COleControl::ForwardActivationMsg(LPMSG pMsg)
  287. {
  288.     UINT uMsg = pMsg->message;
  289.     LPARAM lParam = pMsg->lParam;
  290.  
  291.     if (m_bInPlaceSiteWndless)
  292.     {
  293.         // For mouse messages, convert to container window's coordinates
  294.         if ((uMsg >= WM_MOUSEFIRST) && (uMsg <= WM_MOUSELAST))
  295.         {
  296.             POINT ptNew = pMsg->pt;
  297.             HWND hWndContainer = NULL;
  298.             if (SUCCEEDED(m_pInPlaceSite->GetWindow(&hWndContainer)))
  299.             {
  300.                 ::ScreenToClient(hWndContainer, &ptNew);
  301.                 lParam = MAKELONG((short)ptNew.x, (short)ptNew.y);
  302.             }
  303.         }
  304.  
  305.         // Process message on behalf of windowless control
  306.         OnWindowlessMessage(uMsg, pMsg->wParam, lParam, NULL);
  307.     }
  308.     else
  309.     {
  310.         // For mouse messages, convert to this window's coordinates
  311.         if ((uMsg >= WM_MOUSEFIRST) && (uMsg <= WM_MOUSELAST))
  312.         {
  313.             POINT ptNew = pMsg->pt;
  314.             ScreenToClient(&ptNew);
  315.             lParam = MAKELONG((short)ptNew.x, (short)ptNew.y);
  316.         }
  317.  
  318.         // Pass the message along to the control's window
  319.         SendMessage(uMsg, pMsg->wParam, lParam);
  320.     }
  321. }
  322.  
  323. HMENU COleControl::OnGetInPlaceMenu()
  324. {
  325.     // Default: no in-place menu
  326.     return NULL;
  327. }
  328.  
  329. BOOL COleControl::BuildSharedMenu()
  330. {
  331.     // This can be called more than once on mouse clicks
  332.     if (m_pUIActiveInfo != NULL)
  333.     {
  334.         ASSERT(m_pUIActiveInfo->m_hSharedMenu != NULL);
  335.         return TRUE;
  336.     }
  337.  
  338.     HMENU hMenu = m_bUIDead ? NULL : OnGetInPlaceMenu();
  339.     TRY
  340.     {
  341.         m_pUIActiveInfo = new _AFXCTL_UIACTIVE_INFO(hMenu, m_pInPlaceFrame);
  342.     }
  343.     END_TRY
  344.  
  345.     return (m_pUIActiveInfo != NULL) && (m_pUIActiveInfo->m_hOleMenu != NULL);
  346. }
  347.  
  348. void COleControl::DestroySharedMenu()
  349. {
  350.     ASSERT(m_pUIActiveInfo != NULL);
  351.     if (m_pUIActiveInfo == NULL)
  352.         return;
  353.  
  354.     HMENU hInPlaceMenu = NULL;
  355.  
  356.     if ((m_pUIActiveInfo->m_hSharedMenu != NULL) &&
  357.         ((hInPlaceMenu = OnGetInPlaceMenu()) != NULL))
  358.     {
  359.         // remove our menu popups from the shared menu
  360.         AfxUnmergeMenus(m_pUIActiveInfo->m_hSharedMenu, hInPlaceMenu);
  361.  
  362.         // allow container to remove its items from the menu
  363.         ASSERT(m_pInPlaceFrame != NULL);
  364.         VERIFY(m_pInPlaceFrame->RemoveMenus(m_pUIActiveInfo->m_hSharedMenu) == S_OK);
  365.     }
  366.  
  367.     delete m_pUIActiveInfo;
  368.     m_pUIActiveInfo = NULL;
  369. }
  370.  
  371. void COleControl::AddFrameLevelUI()
  372. {
  373.     ASSERT(m_pUIActiveInfo != NULL);
  374.     if (m_pUIActiveInfo == NULL)
  375.         return;
  376.  
  377.     m_pInPlaceFrame->SetMenu(m_pUIActiveInfo->m_hSharedMenu,
  378.         m_pUIActiveInfo->m_hOleMenu, m_hWnd);
  379.     OnShowToolBars();
  380. }
  381.  
  382. void COleControl::RemoveFrameLevelUI()
  383. {
  384.     ASSERT(m_pUIActiveInfo != NULL);
  385.     if (m_pUIActiveInfo == NULL)
  386.         return;
  387.  
  388.     OnHideToolBars();
  389.  
  390.     // allow container to remove its items from the menu
  391.     ASSERT(m_pInPlaceFrame != NULL);
  392.     if (m_pUIActiveInfo->m_hSharedMenu != NULL)
  393.         VERIFY(m_pInPlaceFrame->RemoveMenus(m_pUIActiveInfo->m_hSharedMenu) == S_OK);
  394. }
  395.  
  396. void COleControl::OnShowToolBars()
  397. {
  398.     // Default sets border space to empty.
  399.     // When overriding, don't call this implementation.
  400.  
  401.     m_pInPlaceFrame->SetBorderSpace(NULL);
  402. }
  403.  
  404. void COleControl::OnHideToolBars()
  405. {
  406.     // Default does nothing
  407. }
  408.  
  409. /////////////////////////////////////////////////////////////////////////////
  410. // COleControl::XOleInPlaceObject
  411.  
  412. STDMETHODIMP_(ULONG) COleControl::XOleInPlaceObject::AddRef()
  413. {
  414.     METHOD_PROLOGUE_EX_(COleControl, OleInPlaceObject)
  415.     return (ULONG)pThis->ExternalAddRef();
  416. }
  417.  
  418. STDMETHODIMP_(ULONG) COleControl::XOleInPlaceObject::Release()
  419. {
  420.     METHOD_PROLOGUE_EX_(COleControl, OleInPlaceObject)
  421.     return (ULONG)pThis->ExternalRelease();
  422. }
  423.  
  424. STDMETHODIMP COleControl::XOleInPlaceObject::QueryInterface(
  425.     REFIID iid, LPVOID* ppvObj)
  426. {
  427.     METHOD_PROLOGUE_EX_(COleControl, OleInPlaceObject)
  428.     return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  429. }
  430.  
  431. STDMETHODIMP COleControl::XOleInPlaceObject::GetWindow(HWND* lphwnd)
  432. {
  433.     METHOD_PROLOGUE_EX_(COleControl, OleInPlaceObject)
  434.     *lphwnd = pThis->m_bInPlaceActive ? pThis->GetOuterWindow()->m_hWnd : NULL;
  435.     return (*lphwnd != NULL) ? S_OK : E_FAIL;
  436. }
  437.  
  438. STDMETHODIMP COleControl::XOleInPlaceObject::ContextSensitiveHelp(BOOL)
  439. {
  440.     return E_NOTIMPL;
  441. }
  442.  
  443. STDMETHODIMP COleControl::XOleInPlaceObject::InPlaceDeactivate()
  444. {
  445.     METHOD_PROLOGUE_EX(COleControl, OleInPlaceObject)
  446.  
  447.     if (!pThis->m_bInPlaceActive)
  448.         return S_OK;
  449.  
  450.     pThis->m_bInPlaceActive = FALSE;
  451.  
  452.     if (pThis->m_bUIActive)
  453.         UIDeactivate();
  454.  
  455.     // hide the window
  456.  
  457.     if (pThis->m_bInPlaceSiteEx &&
  458.         (pThis->GetControlFlags() & noFlickerActivate))
  459.     {
  460.         // flicker-free deactivation
  461.         if (! pThis->m_bInPlaceSiteWndless)
  462.         {
  463.             pThis->UpdateWindow();
  464.             pThis->OnHide();
  465.         }
  466.         pThis->m_pInPlaceSiteEx->OnInPlaceDeactivateEx(TRUE);
  467.     }
  468.     else
  469.     {
  470.         // old-style deactivation
  471.         pThis->OnHide();
  472.         pThis->m_pInPlaceSite->OnInPlaceDeactivate();
  473.     }
  474.  
  475.     return S_OK;
  476. }
  477.  
  478. STDMETHODIMP COleControl::XOleInPlaceObject::UIDeactivate()
  479. {
  480.     METHOD_PROLOGUE_EX(COleControl, OleInPlaceObject)
  481.  
  482.     pThis->m_bPendingUIActivation = FALSE;
  483.     if (!pThis->m_bUIActive)
  484.         return S_OK;
  485.  
  486.     pThis->DestroyTracker();
  487.     pThis->m_bUIActive = FALSE;
  488.  
  489.     if (pThis->m_pInPlaceDoc != NULL)
  490.         pThis->m_pInPlaceDoc->SetActiveObject(NULL, NULL);
  491.     pThis->m_pInPlaceFrame->SetActiveObject(NULL, NULL);
  492.     pThis->RemoveFrameLevelUI();
  493.     pThis->DestroySharedMenu();
  494.  
  495.     pThis->m_pInPlaceSite->OnUIDeactivate(FALSE);
  496.  
  497.     return S_OK;
  498. }
  499.  
  500. STDMETHODIMP COleControl::XOleInPlaceObject::SetObjectRects(LPCRECT lprcPosRect,
  501.                     LPCRECT lprcClipRect)
  502. {
  503.     METHOD_PROLOGUE_EX(COleControl, OleInPlaceObject)
  504.  
  505.     return pThis->OnSetObjectRects(lprcPosRect, lprcClipRect) ?
  506.             S_OK :
  507.             E_FAIL;
  508. }
  509.  
  510. BOOL COleControl::OnSetObjectRects(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
  511. {
  512.     ASSERT(lprcPosRect != NULL);
  513.  
  514.     // Remember the position rectangle for later
  515.     m_rcPos = *lprcPosRect;
  516.  
  517.     // Calculate complete rectangle including the tracker (if present)
  518.     CRect rectPos = m_rcPos;
  519.     if (m_bUIActive && m_pRectTracker != NULL)
  520.     {
  521.         // Save new clipping rectangle (for DestroyTracker)
  522.         if (lprcClipRect != NULL)
  523.             m_pRectTracker->m_rectClip = *lprcClipRect;
  524.  
  525.         // Adjust tracker rectangle to new dimensions
  526.         CRect rectTmp = rectPos;
  527.         rectTmp.OffsetRect(-rectTmp.left, -rectTmp.top);
  528.         m_pRectTracker->m_rect = rectTmp;
  529.  
  530.         // Adjust the "true" rectangle to include handles/hatching
  531.         UINT nHandleSize = m_pRectTracker->m_nHandleSize - 1;
  532.         rectPos.InflateRect(nHandleSize, nHandleSize);
  533.     }
  534.  
  535.     // Now clip that rectangle as appropriate
  536.     CRect rectClip;
  537.     _GetClippingCoordinates(rectPos, lprcClipRect, rectClip, &m_ptOffset);
  538.  
  539.     // Move outer window first. then inner window
  540.  
  541.     if (!m_bInPlaceSiteWndless)
  542.     {
  543.         CWnd* pWndOuter = GetOuterWindow();
  544.         pWndOuter->MoveWindow(rectClip);
  545.         if (pWndOuter != this)
  546.             MoveWindow(m_ptOffset.x, m_ptOffset.y, rectPos.Width(), rectPos.Height());
  547.     }
  548.  
  549.     return TRUE;
  550. }
  551.  
  552. STDMETHODIMP COleControl::XOleInPlaceObject::ReactivateAndUndo()
  553. {
  554.     return E_NOTIMPL;
  555. }
  556.  
  557. /////////////////////////////////////////////////////////////////////////////
  558. // COleControl::XOleInPlaceActiveObject
  559.  
  560. STDMETHODIMP_(ULONG) COleControl::XOleInPlaceActiveObject::AddRef()
  561. {
  562.     METHOD_PROLOGUE_EX_(COleControl, OleInPlaceActiveObject)
  563.     return (ULONG)pThis->ExternalAddRef();
  564. }
  565.  
  566. STDMETHODIMP_(ULONG) COleControl::XOleInPlaceActiveObject::Release()
  567. {
  568.     METHOD_PROLOGUE_EX_(COleControl, OleInPlaceActiveObject)
  569.     return (ULONG)pThis->ExternalRelease();
  570. }
  571.  
  572. STDMETHODIMP COleControl::XOleInPlaceActiveObject::QueryInterface(
  573.     REFIID iid, LPVOID* ppvObj)
  574. {
  575.     METHOD_PROLOGUE_EX_(COleControl, OleInPlaceActiveObject)
  576.     return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
  577. }
  578.  
  579. STDMETHODIMP COleControl::XOleInPlaceActiveObject::GetWindow(HWND* lphwnd)
  580. {
  581.     METHOD_PROLOGUE_EX_(COleControl, OleInPlaceActiveObject)
  582.     return pThis->m_xOleInPlaceObject.GetWindow(lphwnd);
  583. }
  584.  
  585. STDMETHODIMP COleControl::XOleInPlaceActiveObject::ContextSensitiveHelp(BOOL)
  586. {
  587.     return E_NOTIMPL;
  588. }
  589.  
  590. STDMETHODIMP COleControl::XOleInPlaceActiveObject::TranslateAccelerator(
  591.     LPMSG lpmsg)
  592. {
  593.     METHOD_PROLOGUE_EX(COleControl, OleInPlaceActiveObject)
  594.  
  595.     // Give the control the first chance.
  596.     if (pThis->PreTranslateMessage(lpmsg))
  597.         return S_OK;
  598.  
  599.     // Give the site a chance.
  600.     HRESULT hr = S_FALSE;
  601.     if (pThis->m_pControlSite != NULL)
  602.         hr = pThis->m_pControlSite->TranslateAccelerator(lpmsg,
  603.             (DWORD)_AfxShiftState());
  604.  
  605.     return hr;
  606. }
  607.  
  608. STDMETHODIMP COleControl::XOleInPlaceActiveObject::OnFrameWindowActivate(BOOL)
  609. {
  610.     return S_OK;
  611. }
  612.  
  613. STDMETHODIMP COleControl::XOleInPlaceActiveObject::OnDocWindowActivate(
  614.     BOOL fActivate)
  615. {
  616.     METHOD_PROLOGUE_EX(COleControl, OleInPlaceActiveObject)
  617.  
  618.     if (fActivate && pThis->m_bUIActive)
  619.         pThis->AddFrameLevelUI();
  620.     else
  621.         pThis->OnHideToolBars();
  622.  
  623.     return S_OK;
  624. }
  625.  
  626. STDMETHODIMP COleControl::XOleInPlaceActiveObject::ResizeBorder(
  627.     LPCRECT, LPOLEINPLACEUIWINDOW, BOOL)
  628. {
  629.     return S_OK;
  630. }
  631.  
  632. STDMETHODIMP COleControl::XOleInPlaceActiveObject::EnableModeless(BOOL)
  633. {
  634.     return S_OK;
  635. }
  636.  
  637. /////////////////////////////////////////////////////////////////////////////
  638. // Force any extra compiler-generated code into AFX_INIT_SEG
  639.  
  640. #ifdef AFX_INIT_SEG
  641. #pragma code_seg(AFX_INIT_SEG)
  642. #endif
  643.