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.

302 lines
8.9 KiB

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