Leaked source code of windows server 2003
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.

314 lines
6.9 KiB

  1. /*++
  2. Copyright (C) 1993-1999 Microsoft Corporation
  3. Module Name:
  4. iipaobj.cpp
  5. Abstract:
  6. IOleInPlaceActiveObject interface implementation for Polyline
  7. --*/
  8. #include "polyline.h"
  9. #include "unkhlpr.h"
  10. #include "unihelpr.h"
  11. /*
  12. * CImpIOleInPlaceActiveObject::CImpIOleInPlaceActiveObject
  13. * CImpIOleInPlaceActiveObject::~CImpIOleInPlaceActiveObject
  14. *
  15. * Parameters (Constructor):
  16. * pObj PCPolyline of the object we're in.
  17. * pUnkOuter LPUNKNOWN to which we delegate.
  18. */
  19. IMPLEMENT_CONTAINED_CONSTRUCTOR(CPolyline, CImpIOleInPlaceActiveObject)
  20. IMPLEMENT_CONTAINED_DESTRUCTOR(CImpIOleInPlaceActiveObject)
  21. IMPLEMENT_CONTAINED_ADDREF(CImpIOleInPlaceActiveObject)
  22. IMPLEMENT_CONTAINED_RELEASE(CImpIOleInPlaceActiveObject)
  23. STDMETHODIMP
  24. CImpIOleInPlaceActiveObject::QueryInterface(
  25. REFIID riid,
  26. PPVOID ppv
  27. )
  28. {
  29. HRESULT hr = S_OK;
  30. if (ppv == NULL) {
  31. return E_POINTER;
  32. }
  33. /*
  34. * This interface should be stand-alone on an object such that a
  35. * container cannot QueryInterface for it through any other
  36. * object interface, relying instead of calls to SetActiveObject
  37. * for it. By implementing QueryInterface here ourselves, we
  38. * prevent such abuses. Note that reference counting still uses
  39. * CFigure.
  40. */
  41. try {
  42. *ppv=NULL;
  43. if (IID_IUnknown==riid ||
  44. IID_IOleWindow==riid ||
  45. IID_IOleInPlaceActiveObject==riid) {
  46. *ppv = this;
  47. AddRef();
  48. }
  49. else {
  50. hr = E_NOINTERFACE;
  51. }
  52. } catch (...) {
  53. hr = E_POINTER;
  54. }
  55. return hr;
  56. }
  57. /*
  58. * CImpIOleInPlaceActiveObject::GetWindow
  59. *
  60. * Purpose:
  61. * Retrieves the handle of the window associated with the object on
  62. * which this interface is implemented.
  63. *
  64. * Parameters:
  65. * phWnd HWND * in which to store the window handle.
  66. *
  67. * Return Value:
  68. * HRESULT NOERROR if successful, E_FAIL if there is no
  69. * window.
  70. */
  71. STDMETHODIMP
  72. CImpIOleInPlaceActiveObject::GetWindow(
  73. OUT HWND *phWnd
  74. )
  75. {
  76. HRESULT hr = S_OK;
  77. if (phWnd == NULL) {
  78. return E_POINTER;
  79. }
  80. try {
  81. *phWnd=m_pObj->m_pHW->Window();;
  82. } catch (...) {
  83. hr = E_POINTER;
  84. }
  85. return hr;
  86. }
  87. /*
  88. * CImpIOleInPlaceActiveObject::ContextSensitiveHelp
  89. *
  90. * Purpose:
  91. * Instructs the object on which this interface is implemented to
  92. * enter or leave a context-sensitive help mode.
  93. *
  94. * Parameters:
  95. * fEnterMode BOOL TRUE to enter the mode, FALSE otherwise.
  96. *
  97. * Return Value:
  98. * HRESULT NOERROR or an error code.
  99. */
  100. STDMETHODIMP
  101. CImpIOleInPlaceActiveObject::ContextSensitiveHelp(
  102. BOOL /* fEnterMode */
  103. )
  104. {
  105. return (E_NOTIMPL);
  106. }
  107. /*
  108. * CImpIOleInPlaceActiveObject::TranslateAccelerator
  109. *
  110. * Purpose:
  111. * Requests that the active in-place object translate the message
  112. * given in pMSG if appropriate. This is only called for DLL
  113. * servers where the container's message loop is running. EXE
  114. * servers have control of the message loop so this will not be
  115. * called in such cases.
  116. *
  117. * Parameters:
  118. * pMSG LPMSG to the message to translate.
  119. *
  120. * Return Value:
  121. * HRESULT NOERROR if translates, S_FALSE if not.
  122. */
  123. STDMETHODIMP
  124. CImpIOleInPlaceActiveObject::TranslateAccelerator(
  125. IN LPMSG pMSG
  126. )
  127. {
  128. HRESULT hr = S_OK;
  129. //
  130. // Don't handle keys unless we are UI active
  131. //
  132. if (!m_pObj->m_fUIActive) {
  133. return S_FALSE;
  134. }
  135. try {
  136. // Delegate to the control class
  137. hr = m_pObj->m_pCtrl->TranslateAccelerators(pMSG);
  138. } catch (...) {
  139. hr = E_POINTER;
  140. }
  141. return hr;
  142. }
  143. /*
  144. * CImpIOleInPlaceActiveObject::OnFrameWindowActivate
  145. *
  146. * Purpose:
  147. * Informs the in-place object that the container's frame window
  148. * was either activated or deactivated. Not currently used.
  149. *
  150. * Parameters:
  151. * fActivate BOOL TRUE if the frame is active,
  152. * FALSE otherwise
  153. *
  154. * Return Value:
  155. * HRESULT NOERROR or an error code.
  156. */
  157. STDMETHODIMP
  158. CImpIOleInPlaceActiveObject::OnFrameWindowActivate (
  159. BOOL /* fActivate */
  160. )
  161. {
  162. return E_NOTIMPL;
  163. }
  164. /*
  165. * CImpIOleInPlaceActiveObject::OnDocWindowActivate
  166. *
  167. * Purpose:
  168. * Informs the in-place object that the document window in the
  169. * container is either becoming active or deactive. On this call
  170. * the object must either add or remove frame-level tools,
  171. * including the mixed menu, depending on fActivate.
  172. *
  173. * Parameters:
  174. * fActivate BOOL TRUE if the document is active,
  175. * FALSE otherwise
  176. *
  177. * Return Value:
  178. * HRESULT NOERROR or an error code.
  179. */
  180. STDMETHODIMP
  181. CImpIOleInPlaceActiveObject::OnDocWindowActivate (
  182. BOOL fActivate
  183. )
  184. {
  185. HRESULT hr;
  186. if (NULL==m_pObj->m_pIOleIPFrame) {
  187. return S_OK;
  188. }
  189. if (fActivate) {
  190. hr = m_pObj->m_pIOleIPFrame->SetActiveObject(this, ResourceString(IDS_USERTYPE));
  191. hr = m_pObj->m_pIOleIPFrame->SetMenu(m_pObj->m_hMenuShared,
  192. m_pObj->m_hOLEMenu,
  193. m_pObj->m_pCtrl->Window());
  194. }
  195. else {
  196. hr = m_pObj->m_pIOleIPFrame->SetActiveObject(NULL, NULL);
  197. }
  198. return hr;
  199. }
  200. /*
  201. * CImpIOleInPlaceActiveObject::ResizeBorder
  202. *
  203. * Purpose:
  204. * Informs the object that the frame or document size changed in
  205. * which case the object may need to resize any of its frame or
  206. * document-level tools to match.
  207. *
  208. * Parameters:
  209. * pRect LPCRECT indicating the new size of the window
  210. * of interest.
  211. * pIUIWindow LPOLEINPLACEUIWINDOW pointing to an
  212. * IOleInPlaceUIWindow interface on the container
  213. * object of interest. We use this to do
  214. * border-space negotiation.
  215. *
  216. * fFrame BOOL indicating if the frame was resized (TRUE)
  217. * or the document (FALSE)
  218. *
  219. * Return Value:
  220. * HRESULT NOERROR or an error code.
  221. */
  222. STDMETHODIMP
  223. CImpIOleInPlaceActiveObject::ResizeBorder (
  224. LPCRECT, /* pRect */
  225. LPOLEINPLACEUIWINDOW, /* pIUIWindow */
  226. BOOL /* fFrame */
  227. )
  228. {
  229. return (E_NOTIMPL);
  230. }
  231. /*
  232. * CImpIOleInPlaceActiveObject::EnableModeless
  233. *
  234. * Purpose:
  235. * Instructs the object to show or hide any modeless popup windows
  236. * that it may be using when activated in-place.
  237. *
  238. * Parameters:
  239. * fEnable BOOL indicating to enable/show the windows
  240. * (TRUE) or to hide them (FALSE).
  241. *
  242. * Return Value:
  243. * HRESULT NOERROR or an error code.
  244. */
  245. STDMETHODIMP
  246. CImpIOleInPlaceActiveObject::EnableModeless (
  247. BOOL /* fActivate */
  248. )
  249. {
  250. return (E_NOTIMPL);
  251. }