Source code of Windows XP (NT5)
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.

149 lines
3.5 KiB

  1. #include <assert.h>
  2. #include "ioipsite.h"
  3. #include "iosite.h"
  4. COleInPlaceSite::COleInPlaceSite(COleSite* pSite)
  5. {
  6. m_pOleSite = pSite;
  7. m_nCount = 0;
  8. AddRef();
  9. }
  10. COleInPlaceSite::~COleInPlaceSite()
  11. {
  12. assert(m_nCount == 0);
  13. }
  14. STDMETHODIMP COleInPlaceSite::QueryInterface(REFIID riid, LPVOID* ppvObj)
  15. {
  16. // delegate to the container Site
  17. return m_pOleSite->QueryInterface(riid, ppvObj);
  18. }
  19. STDMETHODIMP_(ULONG) COleInPlaceSite::AddRef()
  20. {
  21. return ++m_nCount;
  22. }
  23. STDMETHODIMP_(ULONG) COleInPlaceSite::Release()
  24. {
  25. --m_nCount;
  26. if(m_nCount == 0)
  27. {
  28. delete this;
  29. return 0;
  30. }
  31. return m_nCount;
  32. }
  33. STDMETHODIMP COleInPlaceSite::GetWindow (HWND* lphwnd)
  34. {
  35. // return the handle to our editing window.
  36. *lphwnd = m_pOleSite->m_hWnd;
  37. return ResultFromScode(S_OK);
  38. }
  39. STDMETHODIMP COleInPlaceSite::ContextSensitiveHelp (BOOL fEnterMode)
  40. {
  41. return ResultFromScode(S_OK);
  42. }
  43. STDMETHODIMP COleInPlaceSite::CanInPlaceActivate ()
  44. {
  45. return ResultFromScode(S_OK);
  46. }
  47. STDMETHODIMP COleInPlaceSite::OnInPlaceActivate ()
  48. {
  49. HRESULT hrErr;
  50. hrErr = m_pOleSite->m_lpOleObject->QueryInterface(IID_IOleInPlaceObject, (LPVOID*)&m_pOleSite->m_lpInPlaceObject);
  51. if (hrErr != NOERROR)
  52. return ResultFromScode(E_FAIL);
  53. // return S_OK to indicate we can in-place activate.
  54. return ResultFromScode(S_OK);
  55. }
  56. STDMETHODIMP COleInPlaceSite::OnUIActivate ()
  57. {
  58. m_pOleSite->m_fInPlaceActive = TRUE;
  59. m_pOleSite->m_lpInPlaceObject->GetWindow((HWND*)&m_pOleSite->m_hwndIPObj);
  60. // return S_OK to continue in-place activation
  61. return ResultFromScode(S_OK);
  62. }
  63. STDMETHODIMP COleInPlaceSite::GetWindowContext (LPOLEINPLACEFRAME* lplpFrame,
  64. LPOLEINPLACEUIWINDOW* lplpDoc,
  65. LPRECT lprcPosRect,
  66. LPRECT lprcClipRect,
  67. LPOLEINPLACEFRAMEINFO lpFrameInfo)
  68. {
  69. RECT rect;
  70. // the frame is associated with the application object.
  71. // need to AddRef() it...
  72. m_pOleSite->m_pOleInPlaceFrame->AddRef();
  73. *lplpFrame = m_pOleSite->m_pOleInPlaceFrame;
  74. *lplpDoc = NULL; // must be NULL, cause we're SDI.
  75. // get the size of the object in pixels
  76. GetClientRect(m_pOleSite->m_hWnd, &rect);
  77. // Copy this to the passed buffer
  78. CopyRect(lprcPosRect, &rect);
  79. // fill the clipping region
  80. GetClientRect(m_pOleSite->m_hWnd, &rect);
  81. CopyRect(lprcClipRect, &rect);
  82. // fill the FRAMEINFO
  83. lpFrameInfo->fMDIApp = FALSE;
  84. lpFrameInfo->hwndFrame = m_pOleSite->m_hWnd;
  85. lpFrameInfo->haccel = NULL;
  86. lpFrameInfo->cAccelEntries = 0;
  87. return ResultFromScode(S_OK);
  88. }
  89. STDMETHODIMP COleInPlaceSite::Scroll (SIZE scrollExtent)
  90. {
  91. return ResultFromScode(E_FAIL);
  92. }
  93. STDMETHODIMP COleInPlaceSite::OnUIDeactivate (BOOL fUndoable)
  94. {
  95. // need to clear this flag first
  96. m_pOleSite->m_fInPlaceActive = FALSE;
  97. return ResultFromScode(S_OK);
  98. }
  99. STDMETHODIMP COleInPlaceSite::OnInPlaceDeactivate ()
  100. {
  101. if (m_pOleSite->m_lpInPlaceObject) {
  102. m_pOleSite->m_lpInPlaceObject->Release();
  103. m_pOleSite->m_lpInPlaceObject = NULL;
  104. }
  105. return ResultFromScode(S_OK);
  106. }
  107. STDMETHODIMP COleInPlaceSite::DiscardUndoState ()
  108. {
  109. return ResultFromScode(E_FAIL);
  110. }
  111. STDMETHODIMP COleInPlaceSite::DeactivateAndUndo ()
  112. {
  113. return ResultFromScode(E_FAIL);
  114. }
  115. STDMETHODIMP COleInPlaceSite::OnPosRectChange (LPCRECT lprcPosRect)
  116. {
  117. return ResultFromScode(S_OK);
  118. }