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.

276 lines
7.1 KiB

  1. // Copyright (C) 1996-1997 Microsoft Corporation. All rights reserved.
  2. //
  3. // implementation of the OCX 96 interfaces that don't quite fit in to the
  4. // categories covered by embedding, persistence, and ctlmisc.cpp
  5. //
  6. //
  7. #include "header.h"
  8. #include "internet.h"
  9. //=--------------------------------------------------------------------------=
  10. // COleControl::GetActivationPolicy [IPointerInactive]
  11. //=--------------------------------------------------------------------------=
  12. // returns the present activation policy for this object. for non-subclassed
  13. // windows controls, this means we can put off in-place activation for quite
  14. // a while.
  15. //
  16. // Parameters:
  17. // DWORD * - [out] activation policy
  18. //
  19. // Output:
  20. // HRESULT
  21. //
  22. // Notes:
  23. //
  24. STDMETHODIMP COleControl::GetActivationPolicy
  25. (
  26. DWORD *pdwPolicy
  27. )
  28. {
  29. CHECK_POINTER(pdwPolicy);
  30. // just get the policy in the global structure describing this control.
  31. //
  32. *pdwPolicy = ACTIVATIONPOLICYOFCONTROL(m_ObjectType);
  33. return S_OK;
  34. }
  35. //=--------------------------------------------------------------------------=
  36. // COleControl::OnInactiveMouseMove [IPointerInactive]
  37. //=--------------------------------------------------------------------------=
  38. // indicates to an inactive oobject that the mouse pointer has moved over the
  39. // object.
  40. //
  41. // Parameters:
  42. // LPCRECT - [in]
  43. // long - [in]
  44. // long - [in]
  45. // DWORD - [in]
  46. //
  47. // Output:
  48. // HRESULT
  49. //
  50. // Notes:
  51. //
  52. STDMETHODIMP COleControl::OnInactiveMouseMove
  53. (
  54. LPCRECT pRectBounds,
  55. long x,
  56. long y,
  57. DWORD dwMouseMsg
  58. )
  59. {
  60. // OVERRIDE: end control writers should just override this if they want
  61. // to have a control that is never in-place active.
  62. //
  63. return S_OK;
  64. }
  65. //=--------------------------------------------------------------------------=
  66. // COleControl::OnInactiveSetCursor [IPointerInactive]
  67. //=--------------------------------------------------------------------------=
  68. // called by the container for the inactive object under the mouse pointer on
  69. // recept of a WM_SETCURSOR message.
  70. //
  71. // Parameters:
  72. // LPCRECT - [in]
  73. // long - [in]
  74. // long - [in]
  75. // DWORD - [in]
  76. // BOOL - [in]
  77. //
  78. // Output:
  79. // HRESULT
  80. //
  81. // Notes:
  82. //
  83. STDMETHODIMP COleControl::OnInactiveSetCursor
  84. (
  85. LPCRECT pRectBounds,
  86. long x,
  87. long y,
  88. DWORD dwMouseMsg,
  89. BOOL fSetAlways
  90. )
  91. {
  92. // OVERRIDE: just get the user to override this if they want to never
  93. // be activated
  94. //
  95. return S_OK;
  96. }
  97. //=--------------------------------------------------------------------------=
  98. // COleControl::QuickActivate [IQuickActivate]
  99. //=--------------------------------------------------------------------------=
  100. // allows the container to activate the control.
  101. //
  102. // Parameters:
  103. // QACONTAINER * - [in] info about the container
  104. // QACONTROL * - [out] info about the control
  105. //
  106. // Output:
  107. // HRESULT
  108. //
  109. // Notes:
  110. //
  111. STDMETHODIMP COleControl::QuickActivate
  112. (
  113. QACONTAINER *pContainer,
  114. QACONTROL *pControl
  115. )
  116. {
  117. HRESULT hr;
  118. DWORD dw;
  119. // we need these guys.
  120. //
  121. if (!pContainer) return E_UNEXPECTED;
  122. if (!pControl) return E_UNEXPECTED;
  123. // start grabbing things from the QACONTAINER structure and apply them
  124. // as relevant
  125. //
  126. if (pContainer->cbSize < sizeof(QACONTAINER)) return E_UNEXPECTED;
  127. if (pControl->cbSize < sizeof(QACONTROL)) return E_UNEXPECTED;
  128. // save out the client site, of course.
  129. //
  130. if (pContainer->pClientSite) {
  131. hr = SetClientSite(pContainer->pClientSite);
  132. RETURN_ON_FAILURE(hr);
  133. }
  134. // if the lcid is not LANG_NEUTRAL, score!
  135. //
  136. if (pContainer->lcid) {
  137. g_lcidLocale = pContainer->lcid;
  138. g_fHaveLocale = TRUE;
  139. }
  140. // hook up some notifications. first property notifications.
  141. if (pContainer->pPropertyNotifySink) {
  142. pContainer->pPropertyNotifySink->AddRef();
  143. hr = m_cpPropNotify.AddSink((void *)pContainer->pPropertyNotifySink, &pControl->dwPropNotifyCookie);
  144. if (FAILED(hr)) {
  145. pContainer->pPropertyNotifySink->Release();
  146. return hr;
  147. }
  148. }
  149. // then the event sink.
  150. //
  151. if (pContainer->pUnkEventSink) {
  152. hr = m_cpEvents.Advise(pContainer->pUnkEventSink, &pControl->dwEventCookie);
  153. if (FAILED(hr)) {
  154. pContainer->pUnkEventSink->Release();
  155. return hr;
  156. }
  157. }
  158. // finally, the advise sink.
  159. //
  160. if (pContainer->pAdviseSink) {
  161. // don't need to pass the cookie back since there can only be one
  162. // person advising at a time.
  163. //
  164. hr = Advise(pContainer->pAdviseSink, &dw);
  165. RETURN_ON_FAILURE(hr);
  166. }
  167. // set up a few things in the QACONTROL structure. we're opaque by default
  168. //
  169. pControl->dwMiscStatus = OLEMISCFLAGSOFCONTROL(m_ObjectType);
  170. pControl->dwViewStatus = FCONTROLISOPAQUE(m_ObjectType) ? VIEWSTATUS_OPAQUE : 0;
  171. pControl->dwPointerActivationPolicy = ACTIVATIONPOLICYOFCONTROL(m_ObjectType);
  172. // that's pretty much all we're interested in. we will, however, pass on the
  173. // rest of the things to the end control writer and see if they want to do
  174. // anything with them. they shouldn't touch any of the above except for the
  175. // ambients.
  176. //
  177. return OnQuickActivate(pContainer, &(pControl->dwViewStatus));
  178. }
  179. //=--------------------------------------------------------------------------=
  180. // COleControl::SetContentExtent [IQuickActivate]
  181. //=--------------------------------------------------------------------------=
  182. // the container calls this to set the content extent of the control.
  183. //
  184. // Parameters:
  185. // LPSIZEL - [in] the size of the content extent
  186. //
  187. // Output:
  188. // HRESULT - S_OK, or E_FAIL for fixed size control
  189. //
  190. // Notes:
  191. //
  192. STDMETHODIMP COleControl::SetContentExtent
  193. (
  194. LPSIZEL pSize
  195. )
  196. {
  197. return SetExtent(DVASPECT_CONTENT, pSize);
  198. }
  199. //=--------------------------------------------------------------------------=
  200. // COleControl::GetContentExtent [IQuickActivate]
  201. //=--------------------------------------------------------------------------=
  202. // the container calls this to get the content extent of the control
  203. //
  204. // Parameters:
  205. // LPSIZEL - [out] returns current size
  206. //
  207. // Output:
  208. // HRESULT
  209. //
  210. // Notes:
  211. //
  212. STDMETHODIMP COleControl::GetContentExtent
  213. (
  214. LPSIZEL pSize
  215. )
  216. {
  217. return GetExtent(DVASPECT_CONTENT, pSize);
  218. }
  219. //=--------------------------------------------------------------------------=
  220. // COleControl::OnQuickActivate [overridable]
  221. //=--------------------------------------------------------------------------=
  222. // not all the of the members of the QACONTAINER need to be consumed by the
  223. // framework, but are, at least, extremely interesting. thus, we will pass
  224. // on the struture to the end control writer, and let them consume these.
  225. //
  226. // Parameters:
  227. // QACONTAINER * - [in] contains additional information
  228. // DWORD * - [out] put ViewStatus flags here.
  229. //
  230. // Output:
  231. // HRESULT
  232. //
  233. // Notes:
  234. // - control writers should only look at/consume:
  235. // a. dwAmbientFlags
  236. // b. colorFore/colorBack
  237. // c. pFont
  238. // d. pUndoMgr
  239. // e. dwAppearance
  240. // f. hpal
  241. //
  242. // - all the others are set up the for the user by the framework.
  243. // - control writers should set up the pdwViewStatus with flags as per
  244. // IViewObjectEx::GetViewStatus. if you don't know what this is or don't
  245. // care, then don't touch.
  246. //
  247. HRESULT COleControl::OnQuickActivate
  248. (
  249. QACONTAINER *pContainer,
  250. DWORD *pdwViewStatus
  251. )
  252. {
  253. // by default, nuthin much to do!
  254. //
  255. return S_OK;
  256. }