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.

293 lines
8.3 KiB

  1. //=--------------------------------------------------------------------------=
  2. // CtlOcx96.H
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995-1996 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 "IPServer.H"
  17. #include "CtrlObj.H"
  18. #include "Globals.H"
  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. DWORD dw;
  129. // we need these guys.
  130. //
  131. if (!pContainer) return E_UNEXPECTED;
  132. if (!pControl) return E_UNEXPECTED;
  133. // start grabbing things from the QACONTAINER structure and apply them
  134. // as relevant
  135. //
  136. if (pContainer->cbSize < sizeof(QACONTAINER)) return E_UNEXPECTED;
  137. if (pControl->cbSize < sizeof(QACONTROL)) return E_UNEXPECTED;
  138. // save out the client site, of course.
  139. //
  140. if (pContainer->pClientSite) {
  141. hr = SetClientSite(pContainer->pClientSite);
  142. RETURN_ON_FAILURE(hr);
  143. }
  144. // if the lcid is not LANG_NEUTRAL, score!
  145. //
  146. if (pContainer->lcid) {
  147. g_lcidLocale = pContainer->lcid;
  148. g_fHaveLocale = TRUE;
  149. }
  150. // pay attention to some ambients
  151. //
  152. if (pContainer->dwAmbientFlags & QACONTAINER_MESSAGEREFLECT) {
  153. m_fHostReflects = TRUE;
  154. m_fCheckedReflecting = TRUE;
  155. }
  156. // hook up some notifications. first property notifications.
  157. //
  158. if (pContainer->pPropertyNotifySink) {
  159. pContainer->pPropertyNotifySink->AddRef();
  160. hr = m_cpPropNotify.AddSink((void *)pContainer->pPropertyNotifySink, &pControl->dwPropNotifyCookie);
  161. if (FAILED(hr)) {
  162. pContainer->pPropertyNotifySink->Release();
  163. return hr;
  164. }
  165. }
  166. // then the event sink.
  167. //
  168. if (pContainer->pUnkEventSink) {
  169. hr = m_cpEvents.Advise(pContainer->pUnkEventSink, &pControl->dwEventCookie);
  170. if (FAILED(hr)) {
  171. pContainer->pUnkEventSink->Release();
  172. return hr;
  173. }
  174. }
  175. // finally, the advise sink.
  176. //
  177. if (pContainer->pAdviseSink) {
  178. // don't need to pass the cookie back since there can only be one
  179. // person advising at a time.
  180. //
  181. hr = Advise(pContainer->pAdviseSink, &dw);
  182. RETURN_ON_FAILURE(hr);
  183. }
  184. // set up a few things in the QACONTROL structure. we're opaque by default
  185. //
  186. pControl->dwMiscStatus = OLEMISCFLAGSOFCONTROL(m_ObjectType);
  187. pControl->dwViewStatus = FCONTROLISOPAQUE(m_ObjectType) ? VIEWSTATUS_OPAQUE : 0;
  188. pControl->dwPointerActivationPolicy = ACTIVATIONPOLICYOFCONTROL(m_ObjectType);
  189. // that's pretty much all we're interested in. we will, however, pass on the
  190. // rest of the things to the end control writer and see if they want to do
  191. // anything with them. they shouldn't touch any of the above except for the
  192. // ambients.
  193. //
  194. return OnQuickActivate(pContainer, &(pControl->dwViewStatus));
  195. }
  196. //=--------------------------------------------------------------------------=
  197. // COleControl::SetContentExtent [IQuickActivate]
  198. //=--------------------------------------------------------------------------=
  199. // the container calls this to set the content extent of the control.
  200. //
  201. // Parameters:
  202. // LPSIZEL - [in] the size of the content extent
  203. //
  204. // Output:
  205. // HRESULT - S_OK, or E_FAIL for fixed size control
  206. //
  207. // Notes:
  208. //
  209. STDMETHODIMP COleControl::SetContentExtent
  210. (
  211. LPSIZEL pSize
  212. )
  213. {
  214. return SetExtent(DVASPECT_CONTENT, pSize);
  215. }
  216. //=--------------------------------------------------------------------------=
  217. // COleControl::GetContentExtent [IQuickActivate]
  218. //=--------------------------------------------------------------------------=
  219. // the container calls this to get the content extent of the control
  220. //
  221. // Parameters:
  222. // LPSIZEL - [out] returns current size
  223. //
  224. // Output:
  225. // HRESULT
  226. //
  227. // Notes:
  228. //
  229. STDMETHODIMP COleControl::GetContentExtent
  230. (
  231. LPSIZEL pSize
  232. )
  233. {
  234. return GetExtent(DVASPECT_CONTENT, pSize);
  235. }
  236. //=--------------------------------------------------------------------------=
  237. // COleControl::OnQuickActivate [overridable]
  238. //=--------------------------------------------------------------------------=
  239. // not all the of the members of the QACONTAINER need to be consumed by the
  240. // framework, but are, at least, extremely interesting. thus, we will pass
  241. // on the struture to the end control writer, and let them consume these.
  242. //
  243. // Parameters:
  244. // QACONTAINER * - [in] contains additional information
  245. // DWORD * - [out] put ViewStatus flags here.
  246. //
  247. // Output:
  248. // HRESULT
  249. //
  250. // Notes:
  251. // - control writers should only look at/consume:
  252. // a. dwAmbientFlags
  253. // b. colorFore/colorBack
  254. // c. pFont
  255. // d. pUndoMgr
  256. // e. dwAppearance
  257. // f. hpal
  258. //
  259. // - all the others are set up the for the user by the framework.
  260. // - control writers should set up the pdwViewStatus with flags as per
  261. // IViewObjectEx::GetViewStatus. if you don't know what this is or don't
  262. // care, then don't touch.
  263. //
  264. HRESULT COleControl::OnQuickActivate
  265. (
  266. QACONTAINER *pContainer,
  267. DWORD *pdwViewStatus
  268. )
  269. {
  270. // by default, nuthin much to do!
  271. //
  272. return S_OK;
  273. }