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.

526 lines
24 KiB

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