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