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.

201 lines
8.1 KiB

  1. /*************************************************************************/
  2. /* Copyright (C) 1999 Microsoft Corporation */
  3. /* File: CCObj.h */
  4. /* Description: Contains holder for container objects. */
  5. /*************************************************************************/
  6. #ifndef __CCOBJ_H
  7. #define __CCOBJ_H
  8. //#include "chobj.h"
  9. class CHostedObject;
  10. /*************************************************************************/
  11. /* Class: CContainerObject */
  12. /* Description: Object that contains container. This is a simple wrapper */
  13. /* inorder to have really just one cobtainer site, but at the same time */
  14. /* support the windowless activation. We pass in this object instead of */
  15. /* the real site, so we can track which windowless object has focus and */
  16. /* or capture. */
  17. /*************************************************************************/
  18. class CContainerObject:
  19. public IOleClientSite,
  20. public IOleInPlaceSiteWindowless,
  21. public IOleContainer,
  22. public IObjectWithSite,
  23. public IPropertyBag,
  24. public IOleControlSite,
  25. public IOleInPlaceFrame
  26. {
  27. protected:
  28. CContainerObject(){Init();};
  29. public:
  30. virtual ~CContainerObject(){ATLTRACE2(atlTraceHosting, 0, TEXT("In the CContainerObject object destructor \n")); ;};
  31. CContainerObject(IUnknown* pUnknown, CHostedObject* pObj);
  32. STDMETHOD(QueryInterface)(const IID& iid, void**ppv);
  33. STDMETHOD_(ULONG,AddRef)( void);
  34. STDMETHOD_(ULONG,Release)( void);
  35. // needed to initialize this object
  36. HRESULT SetObjects(IUnknown* pUnknown, CHostedObject* pObj);
  37. HRESULT InvalidateObjectRect();
  38. // IOleClientSite
  39. STDMETHOD(SaveObject)(){ATLTRACENOTIMPL(_T("IOleClientSite::SaveObject"));}
  40. STDMETHOD(GetMoniker)(DWORD /*dwAssign*/, DWORD /*dwWhichMoniker*/, IMoniker** /*ppmk*/){ATLTRACENOTIMPL(_T("IOleClientSite::GetMoniker"));}
  41. STDMETHOD(GetContainer)(IOleContainer** ppContainer);
  42. STDMETHOD(ShowObject)();
  43. STDMETHOD(OnShowWindow)(BOOL fShow);
  44. STDMETHOD(RequestNewObjectLayout)(){ATLTRACENOTIMPL(_T("IOleClientSite::RequestNewObjectLayout"));}
  45. // IOleWindow
  46. STDMETHOD(GetWindow)(HWND *phwnd);
  47. STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode);
  48. //IOleInPlaceSite
  49. STDMETHOD(CanInPlaceActivate)();
  50. STDMETHOD(OnUIActivate)();
  51. STDMETHOD(OnInPlaceActivate)();
  52. STDMETHOD(GetWindowContext)(IOleInPlaceFrame** ppFrame, IOleInPlaceUIWindow** ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO pFrameInfo);
  53. STDMETHOD(OnUIDeactivate)(BOOL fUndoable);
  54. STDMETHOD(OnInPlaceDeactivate)();
  55. STDMETHOD(DiscardUndoState)();
  56. STDMETHOD(DeactivateAndUndo)();
  57. STDMETHOD(OnPosRectChange)(LPCRECT lprcPosRect);
  58. STDMETHOD(Scroll)(SIZE scrollExtant);
  59. //IOleInPlaceSiteEx
  60. STDMETHOD(OnInPlaceActivateEx)(BOOL* pfNoRedraw, DWORD dwFlags);
  61. STDMETHOD(OnInPlaceDeactivateEx)(BOOL fNoRedraw);
  62. STDMETHOD(RequestUIActivate)();
  63. STDMETHOD(CanWindowlessActivate)();
  64. STDMETHOD(GetCapture)();
  65. STDMETHOD(SetCapture)(BOOL fCapture);
  66. STDMETHOD(GetFocus)();
  67. STDMETHOD(SetFocus)(BOOL fFocus);
  68. STDMETHOD(GetDC)(LPCRECT /*pRect*/, DWORD /*grfFlags*/, HDC* phDC);
  69. STDMETHOD(ReleaseDC)(HDC hDC);
  70. STDMETHOD(InvalidateRect)(LPCRECT pRect, BOOL fErase);
  71. STDMETHOD(InvalidateRgn)(HRGN hRGN = NULL, BOOL fErase = FALSE);
  72. STDMETHOD(ScrollRect)(INT /*dx*/, INT /*dy*/, LPCRECT /*pRectScroll*/, LPCRECT /*pRectClip*/);
  73. STDMETHOD(AdjustRect)(LPRECT /*prc*/);
  74. STDMETHOD(OnDefWindowMessage)(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT* plResult);
  75. // IOleContainer
  76. STDMETHOD(ParseDisplayName)(IBindCtx* /*pbc*/, LPOLESTR /*pszDisplayName*/, ULONG* /*pchEaten*/, IMoniker** /*ppmkOut*/);
  77. STDMETHOD(EnumObjects)(DWORD /*grfFlags*/, IEnumUnknown** ppenum);
  78. STDMETHOD(LockContainer)(BOOL fLock);
  79. //IObjectWithSite
  80. STDMETHOD(SetSite)(IUnknown *pUnkSite){ATLTRACENOTIMPL(_T("IObjectWithSite::SetSite"));}
  81. STDMETHOD(GetSite)(REFIID riid, void **ppvSite);
  82. //IPropertyBag
  83. STDMETHOD(Read)(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog);
  84. STDMETHOD(Write)(LPCOLESTR pszPropName, VARIANT* pVar){ATLTRACENOTIMPL(_T("IPropertyBag::Write"));}
  85. // IOleControlSite
  86. STDMETHOD(OnControlInfoChanged)(){
  87. ATLTRACE2(atlTraceHosting, 2, TEXT("IOleControlSite::OnControlInfoChanged\n"));
  88. return S_OK;
  89. }
  90. STDMETHOD(LockInPlaceActive)(BOOL /*fLock*/)
  91. {
  92. ATLTRACE2(atlTraceHosting, 2, TEXT("IOleControlSite::LockInPlaceActive\n"));
  93. return S_OK;
  94. }
  95. STDMETHOD(GetExtendedControl)(IDispatch** ppDisp);
  96. STDMETHOD(TransformCoords)(POINTL* /*pPtlHimetric*/, POINTF* /*pPtfContainer*/, DWORD /*dwFlags*/)
  97. {
  98. ATLTRACE2(atlTraceHosting, 2, TEXT("IOleControlSite::TransformCoords\n"));
  99. return S_OK;
  100. }
  101. STDMETHOD(TranslateAccelerator)(LPMSG /*lpMsg*/, DWORD /*grfModifiers*/)
  102. {
  103. ATLTRACE2(atlTraceHosting, 2, TEXT("IOleControlSite::TranslateAccelerator\n"));
  104. return S_FALSE;
  105. }
  106. STDMETHOD(OnFocus)(BOOL /*fGotFocus*/)
  107. {
  108. ATLTRACE2(atlTraceHosting, 2, TEXT("IOleControlSite::OnFocus\n"));
  109. return S_OK;
  110. }
  111. STDMETHOD(ShowPropertyFrame)()
  112. {
  113. ATLTRACE2(atlTraceHosting, 2, TEXT("IOleControlSite::ShowPropertyFrame\n"));
  114. return E_NOTIMPL;
  115. }
  116. STDMETHOD(InsertMenus)(HMENU /*hmenuShared*/, LPOLEMENUGROUPWIDTHS /*lpMenuWidths*/)
  117. {
  118. ATLTRACE2(atlTraceHosting, 2, TEXT("CMFBar::InsertMenus\n"));
  119. return S_OK;
  120. }
  121. STDMETHOD(SetMenu)(HMENU /*hmenuShared*/, HOLEMENU /*holemenu*/, HWND /*hwndActiveObject*/)
  122. {
  123. ATLTRACE2(atlTraceHosting, 2, TEXT("CMFBar::SetMenu\n"));
  124. return S_OK;
  125. }
  126. STDMETHOD(RemoveMenus)(HMENU /*hmenuShared*/)
  127. {
  128. ATLTRACE2(atlTraceHosting, 2, TEXT("CMFBar::RemoveMenus\n"));
  129. return S_OK;
  130. }
  131. STDMETHOD(SetStatusText)(LPCOLESTR /*pszStatusText*/)
  132. {
  133. ATLTRACE2(atlTraceHosting, 2, TEXT("CMFBar::SetStatusText\n"));
  134. return S_OK;
  135. }
  136. /********** Implemented somewhere Else ***/
  137. STDMETHOD(EnableModeless)(BOOL /*fEnable*/)
  138. {
  139. return S_OK;
  140. }
  141. STDMETHOD(TranslateAccelerator)(LPMSG /*lpMsg*/, WORD /*wID*/)
  142. {
  143. ATLTRACE2(atlTraceHosting, 2, TEXT("CMFBar::TranslateAccelerator\n"));
  144. return S_FALSE;
  145. }
  146. // IOleWindow
  147. #if 0 // implemented somwhere else, but implementation might need to be revised
  148. STDMETHOD(GetWindow)(HWND* phwnd){
  149. *phwnd = m_hWnd;
  150. return S_OK;
  151. }
  152. STDMETHOD(ContextSensitiveHelp)(BOOL /*fEnterMode*/)
  153. {
  154. ATLTRACE2(atlTraceHosting, 2, TEXT("CMFBar::ContextSensitiveHelp\n"));
  155. return S_OK;
  156. }
  157. #endif
  158. // IOleInPlaceUIWindow
  159. STDMETHOD(GetBorder)(LPRECT lprectBorder);
  160. STDMETHOD(RequestBorderSpace)(LPCBORDERWIDTHS pborderwidths);
  161. STDMETHOD(SetBorderSpace)(LPCBORDERWIDTHS pborderwidths);
  162. STDMETHOD(SetActiveObject)(IOleInPlaceActiveObject* pActiveObject, LPCOLESTR pszObjName);
  163. protected: // helper functions
  164. void Init();
  165. inline HRESULT GetWindowlessSite(CComPtr<IOleInPlaceSiteWindowless>& pSite);
  166. inline HRESULT GetContainer(CComPtr<IOleContainer>& pContainer);
  167. HRESULT ParsePropertyBag(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog);
  168. private: // private member variables
  169. CHostedObject* m_pObj; // object which we are hosting
  170. CComPtr<IUnknown> m_pUnkContainer; // pointer to our container
  171. CComPtr<IOleInPlaceFrame> m_spInPlaceFrame; // cached up pointer
  172. CComPtr<IOleInPlaceUIWindow> m_spInPlaceUIWindow; // cached up pointer
  173. long m_lRefCount;
  174. unsigned long m_bLocked:1;
  175. };/* end of class CContainerObject */
  176. #endif // end of __CCOBJ_H
  177. /*************************************************************************/
  178. /* End of file: CCObj.h */
  179. /*************************************************************************/