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.

536 lines
26 KiB

  1. //=--------------------------------------------------------------------------=
  2. // ControlObject.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. // class declaration for the COleControl object
  13. //
  14. #ifndef _CONTROLOBJECT_H_
  15. // we need the automation object and ctlole.h
  16. //
  17. #include "AutoObj.H"
  18. #include "Macros.H"
  19. // For VC++ 4.2 include files and above, all OCX96.H declarations are in OCIDL.H
  20. // For VB 5.0 build tools, we must include OCX96.H to get this declares.
  21. //
  22. #ifndef __ocidl_h__
  23. #include "ocx96.h"
  24. #endif
  25. // These are the original QA structures. We preserve the declarations here
  26. // because if the structure size changes (i.e., gets larger) in OCIDL.H
  27. // then controls will begin to fail QuickActivate when hosted on older
  28. // containers.
  29. //
  30. typedef struct tagQACONTAINER_OLD
  31. {
  32. ULONG cbSize;
  33. IOleClientSite __RPC_FAR *pClientSite;
  34. IAdviseSinkEx __RPC_FAR *pAdviseSink;
  35. IPropertyNotifySink __RPC_FAR *pPropertyNotifySink;
  36. IUnknown __RPC_FAR *pUnkEventSink;
  37. DWORD dwAmbientFlags;
  38. OLE_COLOR colorFore;
  39. OLE_COLOR colorBack;
  40. IFont __RPC_FAR *pFont;
  41. IOleUndoManager __RPC_FAR *pUndoMgr;
  42. DWORD dwAppearance;
  43. LONG lcid;
  44. HPALETTE hpal;
  45. struct IBindHost __RPC_FAR *pBindHost;
  46. } QACONTAINER_OLD;
  47. typedef struct tagQACONTROL_OLD
  48. {
  49. ULONG cbSize;
  50. DWORD dwMiscStatus;
  51. DWORD dwViewStatus;
  52. DWORD dwEventCookie;
  53. DWORD dwPropNotifyCookie;
  54. DWORD dwPointerActivationPolicy;
  55. } QACONTROL_OLD;
  56. // forward declaration
  57. //
  58. class COleControl;
  59. //=--------------------------------------------------------------------------=
  60. // Misc Helper Functions
  61. //=--------------------------------------------------------------------------=
  62. //
  63. // given an Unknown pointer, get the COleControl * for it. used typically
  64. // in property page code.
  65. //
  66. COleControl *ControlFromUnknown(IUnknown *);
  67. //=--------------------------------------------------------------------------=
  68. // Misc Constants
  69. //=--------------------------------------------------------------------------=
  70. // superclass window support. you can pass this in to DoSuperClassPaint
  71. //
  72. #define DRAW_SENDERASEBACKGROUND 1
  73. //=--------------------------------------------------------------------------=
  74. // Various Hosts don't handle OLEIVERB_PROPERTIES correctly, so we can't use
  75. // that as our Properties verb number. Instead, we're going to define
  76. // CTLIVERB_PROPERTIES as 1, and return that one in IOleObject::EnumVerbs,
  77. // but we'll still handle OLEIVERB_PROPERTIES correctly in DoVerb.
  78. //
  79. #define CTLIVERB_PROPERTIES 1
  80. //=--------------------------------------------------------------------------=
  81. // this structure is like the OLEVERB structure, except that it has a resource ID
  82. // instead of a string for the verb's name. better support for localization.
  83. //
  84. typedef struct tagVERBINFO {
  85. LONG lVerb; // verb id
  86. ULONG idVerbName; // resource ID of verb name
  87. DWORD fuFlags; // verb flags
  88. DWORD grfAttribs; // Specifies some combination of the verb attributes in the OLEVERBATTRIB enumeration.
  89. } VERBINFO;
  90. //=--------------------------------------------------------------------------=
  91. // CONTROLOBJECTINFO
  92. //=--------------------------------------------------------------------------=
  93. // for each control you wish to expose to the programmer/user, you need to
  94. // declare and define one of the following structures. the first part should
  95. // follow the rules of the AUTOMATIONOBJECTINFO structure. it's pretty hard,
  96. // however, to imagine a scenario where the control isn't CoCreatable ...
  97. // once this structre is declared/defined, an entry should be put in the
  98. // global g_ObjectInfo table.
  99. //
  100. typedef struct {
  101. AUTOMATIONOBJECTINFO AutomationInfo; // automation and creation information
  102. DWORD dwOleMiscFlags; // control flags
  103. DWORD dwActivationPolicy; // IPointerInactive support
  104. VARIANT_BOOL fOpaque; // is your control 100% opaque?
  105. VARIANT_BOOL fWindowless; // do we do windowless if we can?
  106. WORD wToolboxId; // resource ID of Toolbox Bitmap
  107. LPCSTR szWndClass; // name of window control class
  108. VARIANT_BOOL fWindowClassRegistered; // has the window class been registered yet?
  109. WORD cPropPages; // number of property pages
  110. const GUID **rgPropPageGuids; // array of the property page GUIDs
  111. WORD cCustomVerbs; // number of custom verbs
  112. const VERBINFO *rgCustomVerbs; // description of custom verbs
  113. WNDPROC pfnSubClass; // for subclassed controls.
  114. } CONTROLOBJECTINFO;
  115. #ifndef INITOBJECTS
  116. #define DEFINE_CONTROLOBJECT(name, clsid, progid, fn, ver, riid, pszh, piide, dwcf, dwap, w, szwc, cpp, rgppg, ccv, rgcv) \
  117. extern CONTROLOBJECTINFO name##Control \
  118. #define DEFINE_WINDOWLESSCONTROLOBJECT(name, clsid, progid, fn, ver, riid, pszh, piide, dwcf, dwap, fo, w, szwc, cpp, rgppg, ccv, rgcv) \
  119. extern CONTROLOBJECTINFO name##Control \
  120. #define DEFINE_CONTROLOBJECT2(name, clsid, progid, lblname, fn, ver, vermin, riid, pszh, piide, dwcf, dwap, w, szwc, cpp, rgppg, ccv, rgcv, fthreadsafe) \
  121. extern CONTROLOBJECTINFO name##Control \
  122. #define DEFINE_WINDOWLESSCONTROLOBJECT2(name, clsid, progid, lblname, fn, ver, vermin, riid, pszh, piide, dwcf, dwap, fo, w, szwc, cpp, rgppg, ccv, rgcv, fthreadsafe) \
  123. extern CONTROLOBJECTINFO name##Control \
  124. #define DEFINE_CONTROLOBJECT3(name, clsid, progid, lblname, precreatefn, fn, ver, vermin, riid, pszh, piide, dwcf, dwap, w, szwc, cpp, rgppg, ccv, rgcv, fthreadsafe) \
  125. extern CONTROLOBJECTINFO name##Control \
  126. #define DEFINE_WINDOWLESSCONTROLOBJECT3(name, clsid, progid, lblname, precreatefn, fn, ver, vermin, riid, pszh, piide, dwcf, dwap, fo, w, szwc, cpp, rgppg, ccv, rgcv, fthreadsafe) \
  127. extern CONTROLOBJECTINFO name##Control \
  128. #else
  129. #define DEFINE_CONTROLOBJECT(name, clsid, progid, fn, ver, riid, pszh, piide, dwcf, dwap, w, szwc, cpp, rgppg, ccv, rgcv) \
  130. CONTROLOBJECTINFO name##Control = { { {clsid, progid, NULL, TRUE, fn, NULL}, ver, 0, riid, piide, pszh, NULL, 0}, dwcf, dwap, TRUE, FALSE, w, szwc, FALSE, cpp, rgppg, ccv, rgcv, NULL} \
  131. #define DEFINE_WINDOWLESSCONTROLOBJECT(name, clsid, progid, fn, ver, riid, pszh, piide, dwcf, dwap, fo, w, szwc, cpp, rgppg, ccv, rgcv) \
  132. CONTROLOBJECTINFO name##Control = { { {clsid, progid, NULL, TRUE, fn, NULL}, ver, 0, riid, piide, pszh, NULL, 0}, dwcf, dwap, fo, TRUE, w, szwc, FALSE, cpp, rgppg, ccv, rgcv, NULL} \
  133. #define DEFINE_CONTROLOBJECT2(name, clsid, progid, lblname, fn, ver, vermin, riid, pszh, piide, dwcf, dwap, w, szwc, cpp, rgppg, ccv, rgcv, fthreadsafe) \
  134. CONTROLOBJECTINFO name##Control = { { {clsid, progid, lblname, fthreadsafe, fn, NULL}, ver, vermin, riid, piide, pszh, NULL, 0}, dwcf, dwap, TRUE, FALSE, w, szwc, FALSE, cpp, rgppg, ccv, rgcv, NULL} \
  135. #define DEFINE_WINDOWLESSCONTROLOBJECT2(name, clsid, progid, lblname, fn, ver, vermin, riid, pszh, piide, dwcf, dwap, fo, w, szwc, cpp, rgppg, ccv, rgcv, fthreadsafe) \
  136. CONTROLOBJECTINFO name##Control = { { {clsid, progid, lblname, fthreadsafe, fn, NULL}, ver, vermin, riid, piide, pszh, NULL, 0}, dwcf, dwap, fo, TRUE, w, szwc, FALSE, cpp, rgppg, ccv, rgcv, NULL} \
  137. #define DEFINE_CONTROLOBJECT3(name, clsid, progid, lblname, precreatefn, fn, ver, vermin, riid, pszh, piide, dwcf, dwap, w, szwc, cpp, rgppg, ccv, rgcv, fthreadsafe) \
  138. CONTROLOBJECTINFO name##Control = { { {clsid, progid, lblname, fthreadsafe, fn, precreatefn}, ver, vermin, riid, piide, pszh, NULL, 0}, dwcf, dwap, TRUE, FALSE, w, szwc, FALSE, cpp, rgppg, ccv, rgcv, NULL} \
  139. #define DEFINE_WINDOWLESSCONTROLOBJECT3(name, clsid, progid, lblname, precreatefn, fn, ver, vermin, riid, pszh, piide, dwcf, dwap, fo, w, szwc, cpp, rgppg, ccv, rgcv, fthreadsafe) \
  140. CONTROLOBJECTINFO name##Control = { { {clsid, progid, lblname, fthreadsafe, fn, precreatefn}, ver, vermin, riid, piide, pszh, NULL, 0}, dwcf, dwap, fo, TRUE, w, szwc, FALSE, cpp, rgppg, ccv, rgcv, NULL} \
  141. #endif // !INITOBJECTS
  142. #define OLEMISCFLAGSOFCONTROL(index) ((CONTROLOBJECTINFO *)(g_ObjectInfo[index].pInfo))->dwOleMiscFlags
  143. #define FCONTROLISWINDOWLESS(index) ((CONTROLOBJECTINFO *)(g_ObjectInfo[index].pInfo))->fWindowless
  144. #define FCONTROLISOPAQUE(index) ((CONTROLOBJECTINFO *)(g_ObjectInfo[index].pInfo))->fOpaque
  145. #define ACTIVATIONPOLICYOFCONTROL(index) ((CONTROLOBJECTINFO *)(g_ObjectInfo[index].pInfo))->dwActivationPolicy
  146. #define WNDCLASSNAMEOFCONTROL(index) ((CONTROLOBJECTINFO *)(g_ObjectInfo[index].pInfo))->szWndClass
  147. #define CPROPPAGESOFCONTROL(index) ((CONTROLOBJECTINFO *)(g_ObjectInfo[index].pInfo))->cPropPages
  148. #define PPROPPAGESOFCONTROL(index) ((CONTROLOBJECTINFO *)(g_ObjectInfo[index].pInfo))->rgPropPageGuids
  149. #define CCUSTOMVERBSOFCONTROL(index) ((CONTROLOBJECTINFO *)(g_ObjectInfo[index].pInfo))->cCustomVerbs
  150. #define CUSTOMVERBSOFCONTROL(index) ((CONTROLOBJECTINFO *)(g_ObjectInfo[index].pInfo))->rgCustomVerbs
  151. #define BITMAPIDOFCONTROL(index) ((CONTROLOBJECTINFO *)(g_ObjectInfo[index].pInfo))->wToolboxId
  152. #define CTLWNDCLASSREGISTERED(index) ((CONTROLOBJECTINFO *)(g_ObjectInfo[index].pInfo))->fWindowClassRegistered
  153. #define SUBCLASSWNDPROCOFCONTROL(index) ((CONTROLOBJECTINFO *)(g_ObjectInfo[index].pInfo))->pfnSubClass
  154. //=--------------------------------------------------------------------------=
  155. // IControlPrv
  156. //=--------------------------------------------------------------------------=
  157. // Interface which allows you to access the COleControl class pointer to
  158. // a control
  159. //
  160. interface IControlPrv : IUnknown
  161. {
  162. STDMETHOD(GetControl)(COleControl **ppCOleControl) PURE;
  163. };
  164. //=--------------------------------------------------------------------------=
  165. // COleControl
  166. //=--------------------------------------------------------------------------=
  167. // the mother of all C++ objects
  168. //
  169. class COleControl : public CAutomationObjectWEvents,
  170. public IOleObject, public IOleControl,
  171. public IOleInPlaceObjectWindowless, public IOleInPlaceActiveObject,
  172. public IViewObjectEx, public IPersistPropertyBag,
  173. public IPersistStreamInit, public IPersistStorage,
  174. public ISpecifyPropertyPages, public IProvideClassInfo,
  175. public IPointerInactive, public IQuickActivate,
  176. public IControlPrv
  177. {
  178. public:
  179. // IUnknown methods -- there are required since we inherit from variuos
  180. // people who themselves inherit from IUnknown. just delegate to controlling
  181. // unknown
  182. //
  183. DECLARE_STANDARD_UNKNOWN();
  184. //=--------------------------------------------------------------------------=
  185. // IPersist methods. used by IPersistStream and IPersistStorage
  186. //
  187. STDMETHOD(GetClassID)(THIS_ LPCLSID lpClassID);
  188. // IPersistStreamInit methods
  189. //
  190. STDMETHOD(IsDirty)(THIS);
  191. STDMETHOD(Load)(LPSTREAM pStm);
  192. STDMETHOD(Save)(LPSTREAM pStm, BOOL fClearDirty);
  193. STDMETHOD(GetSizeMax)(ULARGE_INTEGER FAR* pcbSize);
  194. STDMETHOD(InitNew)();
  195. // IPersistStorage
  196. //
  197. STDMETHOD(InitNew)(IStorage *pStg);
  198. STDMETHOD(Load)(IStorage *pStg);
  199. STDMETHOD(Save)(IStorage *pStgSave, BOOL fSameAsLoad);
  200. STDMETHOD(SaveCompleted)(IStorage *pStgNew);
  201. STDMETHOD(HandsOffStorage)(void);
  202. // IPersistPropertyBag
  203. //
  204. STDMETHOD(Load)(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog);
  205. STDMETHOD(Save)(LPPROPERTYBAG pPropBag, BOOL fClearDirty,
  206. BOOL fSaveAllProperties);
  207. // IOleControl methods
  208. //
  209. STDMETHOD(GetControlInfo)(LPCONTROLINFO pCI);
  210. STDMETHOD(OnMnemonic)(LPMSG pMsg);
  211. STDMETHOD(OnAmbientPropertyChange)(DISPID dispid);
  212. STDMETHOD(FreezeEvents)(BOOL bFreeze);
  213. // IOleObject methods
  214. //
  215. STDMETHOD(SetClientSite)(IOleClientSite *pClientSite);
  216. STDMETHOD(GetClientSite)(IOleClientSite * *ppClientSite);
  217. STDMETHOD(SetHostNames)(LPCOLESTR szContainerApp, LPCOLESTR szContainerObj);
  218. STDMETHOD(Close)(DWORD dwSaveOption);
  219. STDMETHOD(SetMoniker)(DWORD dwWhichMoniker, IMoniker *pmk);
  220. STDMETHOD(GetMoniker)(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker * *ppmk);
  221. STDMETHOD(InitFromData)(IDataObject *pDataObject, BOOL fCreation, DWORD dwReserved);
  222. STDMETHOD(GetClipboardData)(DWORD dwReserved, IDataObject * *ppDataObject);
  223. STDMETHOD(DoVerb)(LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex,
  224. HWND hwndParent, LPCRECT lprcPosRect);
  225. STDMETHOD(EnumVerbs)(IEnumOLEVERB * *ppEnumOleVerb);
  226. STDMETHOD(Update)(void);
  227. STDMETHOD(IsUpToDate)(void);
  228. STDMETHOD(GetUserClassID)(CLSID *pClsid);
  229. STDMETHOD(GetUserType)(DWORD dwFormOfType, LPOLESTR *pszUserType);
  230. STDMETHOD(SetExtent)(DWORD dwDrawAspect,SIZEL *psizel);
  231. STDMETHOD(GetExtent)(DWORD dwDrawAspect, SIZEL *psizel);
  232. STDMETHOD(Advise)(IAdviseSink *pAdvSink, DWORD *pdwConnection);
  233. STDMETHOD(Unadvise)(DWORD dwConnection);
  234. STDMETHOD(EnumAdvise)(IEnumSTATDATA * *ppenumAdvise);
  235. STDMETHOD(GetMiscStatus)(DWORD dwAspect, DWORD *pdwStatus);
  236. STDMETHOD(SetColorScheme)(LOGPALETTE *pLogpal);
  237. // IOleWindow. required for IOleInPlaceObject and IOleInPlaceActiveObject
  238. //
  239. STDMETHOD(GetWindow)(HWND *phwnd);
  240. STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode);
  241. // IOleInPlaceObject/IOleInPlaceObjectWindowless
  242. //
  243. STDMETHOD(InPlaceDeactivate)(void);
  244. STDMETHOD(UIDeactivate)(void);
  245. STDMETHOD(SetObjectRects)(LPCRECT lprcPosRect,LPCRECT lprcClipRect) ;
  246. STDMETHOD(ReactivateAndUndo)(void);
  247. STDMETHOD(OnWindowMessage)(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *plResult);
  248. STDMETHOD(GetDropTarget)(IDropTarget **ppDropTarget);
  249. // IOleInPlaceActiveObject
  250. //
  251. STDMETHOD(TranslateAccelerator)(LPMSG lpmsg);
  252. STDMETHOD(OnFrameWindowActivate)(BOOL fActivate);
  253. STDMETHOD(OnDocWindowActivate)(BOOL fActivate);
  254. STDMETHOD(ResizeBorder)(LPCRECT prcBorder,
  255. IOleInPlaceUIWindow *pUIWindow,
  256. BOOL fFrameWindow);
  257. STDMETHOD(EnableModeless)(BOOL fEnable);
  258. // IViewObject2/IViewObjectEx
  259. //
  260. STDMETHOD(Draw)(DWORD dwDrawAspect, LONG lindex, void *pvAspect,
  261. DVTARGETDEVICE *ptd, HDC hdcTargetDev, HDC hdcDraw,
  262. LPCRECTL lprcBounds, LPCRECTL lprcWBounds,
  263. BOOL ( __stdcall *pfnContinue )(DWORD dwContinue),
  264. DWORD dwContinue);
  265. STDMETHOD(GetColorSet)(DWORD dwDrawAspect,LONG lindex, void *pvAspect,
  266. DVTARGETDEVICE *ptd, HDC hicTargetDev,
  267. LOGPALETTE * *ppColorSet);
  268. STDMETHOD(Freeze)(DWORD dwDrawAspect, LONG lindex,
  269. void *pvAspect,DWORD *pdwFreeze);
  270. STDMETHOD(Unfreeze)(DWORD dwFreeze);
  271. STDMETHOD(SetAdvise)(DWORD aspects, DWORD advf, IAdviseSink *pAdvSink);
  272. STDMETHOD(GetAdvise)(DWORD *pAspects, DWORD *pAdvf, IAdviseSink * *ppAdvSink);
  273. STDMETHOD(GetExtent)(DWORD dwDrawAspect, LONG lindex, DVTARGETDEVICE __RPC_FAR *ptd, LPSIZEL lpsizel);
  274. STDMETHOD(GetRect)(DWORD dwAspect, LPRECTL pRect);
  275. STDMETHOD(GetViewStatus)(DWORD *pdwStatus);
  276. STDMETHOD(QueryHitPoint)(DWORD dwAspect, LPCRECT pRectBounds, POINT ptlLoc, LONG lCloseHint, DWORD *pHitResult);
  277. STDMETHOD(QueryHitRect)(DWORD dwAspect, LPCRECT pRectBounds, LPCRECT prcLoc, LONG lCloseHint, DWORD *pHitResult);
  278. STDMETHOD(GetNaturalExtent)(DWORD dwAspect, LONG lindex, DVTARGETDEVICE *ptd, HDC hicTargetDev, DVEXTENTINFO *pExtentInfo, LPSIZEL psizel);
  279. // ISpecifyPropertyPages
  280. //
  281. STDMETHOD(GetPages)(CAUUID * pPages);
  282. // IProvideClassInfo methods
  283. //
  284. STDMETHOD(GetClassInfo)(LPTYPEINFO * ppTI);
  285. // IPointerInactive methods
  286. //
  287. STDMETHOD(GetActivationPolicy)(DWORD *pdwPolicy);
  288. STDMETHOD(OnInactiveMouseMove)(LPCRECT pRectBounds, long x, long y, DWORD dwMouseMsg);
  289. STDMETHOD(OnInactiveSetCursor)(LPCRECT pRectBounds, long x, long y, DWORD dwMouseMsg, BOOL fSetAlways);
  290. // IQuickActivate methods
  291. //
  292. STDMETHOD(QuickActivate)(QACONTAINER *pqacontainer, QACONTROL *pqacontrol);
  293. STDMETHOD(SetContentExtent)(LPSIZEL);
  294. STDMETHOD(GetContentExtent)(LPSIZEL);
  295. // IControlPrv methods
  296. STDMETHOD(GetControl)(COleControl **pOleControl);
  297. // constructor and destructor
  298. //
  299. COleControl(IUnknown *pUnkOuter, int iPrimaryDispatch, void *pMainInterface);
  300. virtual ~COleControl();
  301. //=--------------------------------------------------------------------------=
  302. // callable by anybody
  303. //
  304. static LRESULT CALLBACK ControlWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
  305. static LRESULT CALLBACK ReflectWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
  306. static LRESULT CALLBACK ParkingWindowProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp);
  307. // You can use this in any parent window to support message reflection
  308. //
  309. static BOOL ReflectOcmMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *pLResult);
  310. static COleControl * ControlFromHwnd(HWND hwnd) {
  311. return (COleControl *) GetWindowLong(hwnd, GWL_USERDATA);
  312. }
  313. HINSTANCE GetResourceHandle(void);
  314. //=--------------------------------------------------------------------------=
  315. // ole controls that want to support both windowed and windowless operations
  316. // should use these wrappers instead of the appropriate win32 api routine.
  317. // controls that don't care and just want to be windowed all the time can
  318. // just go ahead and use the api routines.
  319. //
  320. BOOL SetFocus(BOOL fGrab); // SetFocus API
  321. BOOL OcxGetFocus(void); // GetFocus() == m_hwnd
  322. BOOL OcxGetWindowRect(LPRECT); // gets your current window rect
  323. LRESULT OcxDefWindowProc(UINT, WPARAM, LPARAM); // DefWindowProc
  324. HDC OcxGetDC(void); // GetDC(m_hwnd);
  325. void OcxReleaseDC(HDC hdc); // ReleaseDC(m_hwnd, hdc);
  326. BOOL OcxSetCapture(BOOL fGrab); // SetCapture(fGrab ? m_hwnd : NULL);
  327. BOOL OcxGetCapture(void); // GetCapture() == m_hwnd
  328. BOOL OcxInvalidateRect(LPCRECT, BOOL); // InvalidateRect(m_hwnd, prc, f);
  329. BOOL OcxScrollRect(LPCRECT, LPCRECT, int, int); // ScrollWindowEx(...);
  330. // little routine for people to tell if they are windowless or not
  331. //
  332. inline BOOL Windowless(void) {
  333. return !m_fInPlaceActive || m_pInPlaceSiteWndless;
  334. }
  335. // some people don't care if they're windowed or not -- they just need
  336. // a site pointer. this makes it a little easier.
  337. //
  338. inline IOleInPlaceSite *GetInPlaceSite(void) {
  339. return (IOleInPlaceSite *)(m_pInPlaceSiteWndless ? m_pInPlaceSiteWndless : m_pInPlaceSite);
  340. }
  341. protected:
  342. //=--------------------------------------------------------------------------=
  343. // member variables that derived controls can get at.
  344. //
  345. // derived controls Should NOT modify the following.
  346. //
  347. IOleClientSite *m_pClientSite; // client site
  348. IOleControlSite *m_pControlSite; // IOleControlSite ptr on client site
  349. IOleInPlaceSite *m_pInPlaceSite; // IOleInPlaceSite for managing activation
  350. IOleInPlaceFrame *m_pInPlaceFrame; // IOleInPlaceFrame ptr on client site
  351. IOleInPlaceUIWindow *m_pInPlaceUIWindow; // for negotiating border space with client
  352. ISimpleFrameSite *m_pSimpleFrameSite; // simple frame site
  353. IDispatch *m_pDispAmbient; // ambient dispatch pointer
  354. SIZEL m_Size; // the size of this control
  355. RECT m_rcLocation; // where we at
  356. HWND m_hwnd; // our window
  357. HWND m_hwndParent; // our parent window
  358. // You may need this if you override ::Save
  359. IOleAdviseHolder *m_pOleAdviseHolder; // IOleObject::Advise holder object
  360. // Windowless OLE controls support
  361. //
  362. IOleInPlaceSiteWindowless *m_pInPlaceSiteWndless; // IOleInPlaceSiteWindowless pointer
  363. // flags indicating internal state. do not modify.
  364. //
  365. unsigned m_fDirty:1; // does the control need to be resaved?
  366. unsigned m_fInPlaceActive:1; // are we in place active or not?
  367. unsigned m_fInPlaceVisible:1; // we are in place visible or not?
  368. unsigned m_fUIActive:1; // are we UI active or not.
  369. unsigned m_fCreatingWindow:1; // indicates if we're in CreateWindowEx or not
  370. unsigned m_fSaveSucceeded:1; // did an IStorage save work correctly?
  371. //=--------------------------------------------------------------------------=
  372. // methods that derived controls can override, but may need to be called
  373. // from their versions.
  374. //
  375. virtual void ViewChanged(void);
  376. virtual HRESULT InternalQueryInterface(REFIID riid, void **ppvObjOut);
  377. virtual void BeforeDestroyObject(void);
  378. //=--------------------------------------------------------------------------=
  379. // member functions that provide for derived controls, or that we use, but
  380. // derived controls might still find useful.
  381. //
  382. HRESULT DoSuperClassPaint(HDC, LPCRECTL);
  383. HRESULT RecreateControlWindow(void);
  384. BOOL DesignMode(void);
  385. BOOL GetAmbientProperty(DISPID, VARTYPE, void *);
  386. BOOL GetAmbientFont(IFont **ppFontOut);
  387. void ModalDialog(BOOL fShow);
  388. void InvalidateControl(LPCRECT prc);
  389. BOOL SetControlSize(SIZEL *pSizel);
  390. HWND CreateInPlaceWindow(int x, int y, BOOL fNoRedraw);
  391. HRESULT InPlaceActivate(LONG lVerb);
  392. void SetInPlaceVisible(BOOL);
  393. void SetInPlaceParent(HWND);
  394. // IPropertyNotifySink stuff.
  395. //
  396. inline void PropertyChanged(DISPID dispid) {
  397. m_cpPropNotify.DoOnChanged(dispid);
  398. }
  399. inline BOOL RequestPropertyEdit(DISPID dispid) {
  400. return m_cpPropNotify.DoOnRequestEdit(dispid);
  401. }
  402. // subclassed windows controls support ...
  403. //
  404. inline HWND GetOuterWindow(void) {
  405. return (m_hwndReflect) ? m_hwndReflect : m_hwnd;
  406. }
  407. private:
  408. //=--------------------------------------------------------------------------=
  409. // the following are methods that ALL control writers must override and implement
  410. //
  411. STDMETHOD(LoadBinaryState)(IStream *pStream) PURE;
  412. STDMETHOD(SaveBinaryState)(IStream *pStream) PURE;
  413. STDMETHOD(LoadTextState)(IPropertyBag *pPropertyBag, IErrorLog *pErrorLog) PURE;
  414. STDMETHOD(SaveTextState)(IPropertyBag *pPropertyBag, BOOL fWriteDefault) PURE;
  415. STDMETHOD(OnDraw)(DWORD dvAspect, HDC hdcDraw, LPCRECTL prcBounds, LPCRECTL prcWBounds, HDC hicTargetDev, BOOL fOptimize) PURE;
  416. virtual LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam) PURE;
  417. virtual BOOL RegisterClassData(void) PURE;
  418. //=--------------------------------------------------------------------------=
  419. // OVERRIDABLES -- methods controls can implement for customized functionality
  420. //
  421. virtual void AmbientPropertyChanged(DISPID dispid);
  422. virtual BOOL BeforeCreateWindow(DWORD *, DWORD *, LPSTR);
  423. virtual void BeforeDestroyWindow(void);
  424. virtual HRESULT DoCustomVerb(LONG lVerb);
  425. virtual BOOL OnSetExtent(SIZEL *pSizeL);
  426. virtual BOOL OnSpecialKey(LPMSG);
  427. virtual BOOL OnGetPalette(HDC, LOGPALETTE **);
  428. virtual HRESULT OnQuickActivate(QACONTAINER *, DWORD *);
  429. virtual BOOL InitializeNewState();
  430. virtual BOOL AfterCreateWindow(void);
  431. virtual BOOL OnGetRect(DWORD dvAspect, LPRECTL prcRect);
  432. virtual HRESULT OnSetClientSite(void);
  433. //=--------------------------------------------------------------------------=
  434. // methods that various people internally will share. not needed, however, by
  435. // any inherting classes.
  436. //
  437. HRESULT m_SaveToStream(IStream *pStream);
  438. HRESULT LoadStandardState(IPropertyBag *pPropertyBag, IErrorLog *pErrorLog);
  439. HRESULT LoadStandardState(IStream *pStream);
  440. HRESULT SaveStandardState(IPropertyBag *pPropertyBag);
  441. HRESULT SaveStandardState(IStream *pStream);
  442. //=--------------------------------------------------------------------------=
  443. // member variables we don't want anybody to get their hands on, including
  444. // inheriting classes
  445. //
  446. HWND m_hwndReflect; // for subclassed windows
  447. IAdviseSink *m_pViewAdviseSink; // IViewAdvise sink for IViewObject2
  448. unsigned m_fHostReflects:1; // does the host reflect messages?
  449. unsigned m_fCheckedReflecting:1; // have we checked above yet?
  450. // internal flags. various other flags are visible to the end control class.
  451. //
  452. unsigned m_fModeFlagValid:1; // we stash the mode as much as possible
  453. unsigned m_fViewAdvisePrimeFirst: 1; // for IViewobject2::setadvise
  454. unsigned m_fViewAdviseOnlyOnce: 1; // for iviewobject2::setadvise
  455. unsigned m_fUsingWindowRgn:1; // for SetObjectRects and clipping
  456. unsigned m_fRunMode:1; // are we in run mode or not?
  457. unsigned m_fChangingExtents:1; // Prevent recursive SetExtent calls
  458. };
  459. #define _CONTROLOBJECT_H_
  460. #endif // _CONTROLOBJECT_H_