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.

526 lines
22 KiB

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