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.

295 lines
6.8 KiB

  1. //
  2. // olecli.cpp: Ole Client site
  3. // (For ts activeX control)
  4. //
  5. // Copyright Microsoft Corportation 2000
  6. // (nadima)
  7. //
  8. #include "stdafx.h"
  9. #define TRC_GROUP TRC_GROUP_UI
  10. #define TRC_FILE "olecli.cpp"
  11. #include <atrcapi.h>
  12. #include "olecli.h"
  13. /*--------------------------------------------------------------------------*/
  14. /*
  15. * COleClientSite::COleClientSite
  16. * COleClientSite::~COleClientSite
  17. *
  18. * Constructor Parameters:
  19. * IUnknown to main container interface
  20. */
  21. COleClientSite::COleClientSite(IUnknown *pUnkOuter)
  22. {
  23. m_cRef = 0;
  24. m_pUnkOuter = pUnkOuter;
  25. m_pUnkOuter->AddRef();
  26. }
  27. COleClientSite::~COleClientSite()
  28. {
  29. m_pUnkOuter->Release();
  30. return;
  31. }
  32. /*--------------------------------------------------------------------------*/
  33. /*
  34. * COleClientSite::QueryInterface
  35. * COleClientSite::AddRef
  36. * COleClientSite::Release
  37. */
  38. STDMETHODIMP COleClientSite::QueryInterface( REFIID riid, void ** ppv )
  39. {
  40. return m_pUnkOuter->QueryInterface(riid, ppv);
  41. }
  42. STDMETHODIMP_(ULONG) COleClientSite::AddRef(void)
  43. {
  44. return ++m_cRef;
  45. }
  46. STDMETHODIMP_(ULONG) COleClientSite::Release(void)
  47. {
  48. if (0L != --m_cRef)
  49. return m_cRef;
  50. delete this;
  51. return 0L;
  52. }
  53. /*--------------------------------------------------------------------------*/
  54. /*
  55. * COleClientSite::SaveObject
  56. * COleClientSite::GetMoniker
  57. * COleClientSite::GetContainer
  58. * COleClientSite::ShowObject
  59. * COleClientSite::OnShowWindow
  60. * COleClientSite::RequestNewObjectLayout
  61. */
  62. STDMETHODIMP COleClientSite::SaveObject(void)
  63. {
  64. return NOERROR;
  65. }
  66. STDMETHODIMP COleClientSite::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker,
  67. IMoniker ** ppmk)
  68. {
  69. *ppmk = NULL;
  70. return ResultFromScode(E_NOTIMPL);
  71. }
  72. STDMETHODIMP COleClientSite::GetContainer(LPOLECONTAINER FAR* ppContainer)
  73. {
  74. *ppContainer = NULL;
  75. return ResultFromScode(E_NOTIMPL);
  76. }
  77. STDMETHODIMP COleClientSite::ShowObject(void)
  78. {
  79. return NOERROR;
  80. }
  81. STDMETHODIMP COleClientSite::OnShowWindow(BOOL fShow)
  82. {
  83. return NOERROR;
  84. }
  85. STDMETHODIMP COleClientSite::RequestNewObjectLayout(void)
  86. {
  87. return ResultFromScode(E_NOTIMPL);
  88. }
  89. /*--------------------------------------------------------------------------*/
  90. /*
  91. * COleInPlaceSiteEx::COleInPlaceSiteEx
  92. * COleInPlaceSiteEx::~COleInPlaceSiteEx
  93. *
  94. * Constructor Parameters:
  95. * IUnknown to main container interface
  96. */
  97. COleInPlaceSiteEx::COleInPlaceSiteEx(IUnknown *pUnkOuter)
  98. {
  99. m_cRef = 0;
  100. m_pUnkOuter = pUnkOuter;
  101. m_pUnkOuter->AddRef();
  102. m_hwnd = NULL;
  103. }
  104. COleInPlaceSiteEx::~COleInPlaceSiteEx()
  105. {
  106. m_pUnkOuter->Release();
  107. return;
  108. }
  109. /*--------------------------------------------------------------------------*/
  110. /*
  111. * COleInPlaceSiteEx::QueryInterface
  112. * COleInPlaceSiteEx::AddRef
  113. * COleInPlaceSiteEx::Release
  114. */
  115. STDMETHODIMP COleInPlaceSiteEx::QueryInterface( REFIID riid, void ** ppv )
  116. {
  117. return m_pUnkOuter->QueryInterface(riid, ppv);
  118. }
  119. STDMETHODIMP_(ULONG) COleInPlaceSiteEx::AddRef(void)
  120. {
  121. return ++m_cRef;
  122. }
  123. STDMETHODIMP_(ULONG) COleInPlaceSiteEx::Release(void)
  124. {
  125. if (0L != --m_cRef)
  126. return m_cRef;
  127. delete this;
  128. return 0L;
  129. }
  130. /*--------------------------------------------------------------------------*/
  131. /*
  132. * COleInPlaceSiteEx::SetHwnd
  133. */
  134. STDMETHODIMP_(VOID) COleInPlaceSiteEx::SetHwnd(HWND hwnd)
  135. {
  136. m_hwnd = hwnd;
  137. }
  138. /*--------------------------------------------------------------------------*/
  139. /*
  140. * COleInPlaceSiteEx::GetWindow
  141. * COleInPlaceSiteEx::ContextSensitiveHelp
  142. * COleInPlaceSiteEx::CanInPlaceActivate
  143. * COleInPlaceSiteEx::OnInPlaceActivate
  144. * COleInPlaceSiteEx::OnUIActivate
  145. * COleInPlaceSiteEx::GetWindowContext
  146. * COleInPlaceSiteEx::Scroll
  147. * COleInPlaceSiteEx::OnUIDeactivate
  148. * COleInPlaceSiteEx::OnInPlaceDeactivate
  149. * COleInPlaceSiteEx::DiscardUndoState
  150. * COleInPlaceSiteEx::DeactivateAndUndo
  151. * COleInPlaceSiteEx::OnPosRectChange
  152. * COleInPlaceSiteEx::OnInPlaceActivateEx
  153. * COleInPlaceSiteEx::OnInPlaceDeactivateEx
  154. * COleInPlaceSiteEx::RequestUIActivate
  155. */
  156. STDMETHODIMP COleInPlaceSiteEx::GetWindow(HWND *pHwnd)
  157. {
  158. DC_BEGIN_FN("GetWindow");
  159. TRC_ASSERT(m_hwnd != NULL,
  160. (TB,_T("Somebody called GetWindow before set the Hwnd in InPlaceSite")));
  161. *pHwnd = m_hwnd;
  162. DC_END_FN();
  163. return NOERROR;
  164. }
  165. STDMETHODIMP COleInPlaceSiteEx::ContextSensitiveHelp (BOOL fEnterMode)
  166. {
  167. return NOERROR;
  168. }
  169. STDMETHODIMP COleInPlaceSiteEx::CanInPlaceActivate (void)
  170. {
  171. return NOERROR;
  172. }
  173. STDMETHODIMP COleInPlaceSiteEx::OnInPlaceActivate (void)
  174. {
  175. return NOERROR;
  176. }
  177. STDMETHODIMP COleInPlaceSiteEx::OnUIActivate (void)
  178. {
  179. return NOERROR;
  180. }
  181. STDMETHODIMP COleInPlaceSiteEx::GetWindowContext (IOleInPlaceFrame **ppFrame,
  182. IOleInPlaceUIWindow **ppDoc,
  183. LPRECT lprcPosRect,
  184. LPRECT lprcClipRect,
  185. LPOLEINPLACEFRAMEINFO lpFrameInfo)
  186. {
  187. DC_BEGIN_FN("GetWindowContext");
  188. TRC_ASSERT(lprcPosRect,(TB,_T("lprcPosRect is null")));
  189. TRC_ASSERT(lprcClipRect,(TB,_T("lprcClipRect is null")));
  190. *ppFrame = NULL;
  191. *ppDoc = NULL;
  192. RECT rc;
  193. if(GetClientRect(m_hwnd, &rc))
  194. {
  195. int x = rc.right - rc.left;
  196. int y = rc.bottom - rc.top;
  197. SetRect(lprcClipRect, 0, 0, x, y);
  198. SetRect(lprcPosRect, 0, 0, x, y);
  199. }
  200. else
  201. {
  202. TRC_ERR((TB,_T("GetClientRect returned error:%d"),GetLastError()));
  203. }
  204. #ifndef OS_WINCE
  205. lpFrameInfo = NULL;
  206. #else
  207. //ATL tries to destroy the accelerator table pointed to by lpFrameInfo->hAccel
  208. TRC_ASSERT(lpFrameInfo,(TB,_T("lpFrameInfo is null")));
  209. lpFrameInfo->haccel = NULL;
  210. #endif
  211. DC_END_FN();
  212. return NOERROR;
  213. }
  214. STDMETHODIMP COleInPlaceSiteEx::Scroll (SIZE scrollExtent)
  215. {
  216. return NOERROR;
  217. }
  218. STDMETHODIMP COleInPlaceSiteEx::OnUIDeactivate (BOOL fUndoable)
  219. {
  220. return NOERROR;
  221. }
  222. STDMETHODIMP COleInPlaceSiteEx::OnInPlaceDeactivate (void)
  223. {
  224. return NOERROR;
  225. }
  226. STDMETHODIMP COleInPlaceSiteEx::DiscardUndoState (void)
  227. {
  228. return NOERROR;
  229. }
  230. STDMETHODIMP COleInPlaceSiteEx::DeactivateAndUndo (void)
  231. {
  232. return NOERROR;
  233. }
  234. STDMETHODIMP COleInPlaceSiteEx::OnPosRectChange (LPCRECT lprcPosRect)
  235. {
  236. return NOERROR;
  237. }
  238. STDMETHODIMP COleInPlaceSiteEx::OnInPlaceActivateEx (BOOL *pfNoRedraw, DWORD dwFlags)
  239. {
  240. *pfNoRedraw = TRUE;
  241. return NOERROR;
  242. }
  243. STDMETHODIMP COleInPlaceSiteEx::OnInPlaceDeactivateEx (BOOL fNoRedraw)
  244. {
  245. return NOERROR;
  246. }
  247. STDMETHODIMP COleInPlaceSiteEx::RequestUIActivate (void)
  248. {
  249. return NOERROR;
  250. }