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.

2727 lines
72 KiB

  1. // This is a part of the Active Template Library.
  2. // Copyright (C) 1996-1997 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Active Template Library Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Active Template Library product.
  10. #ifndef __ATLCTL_H__
  11. #define __ATLCTL_H__
  12. #ifndef __cplusplus
  13. #error ATL requires C++ compilation (use a .cpp suffix)
  14. #endif
  15. #include <atlwin.h>
  16. #include <objsafe.h>
  17. #include <urlmon.h>
  18. #pragma comment(lib, "gdi32.lib")
  19. #pragma comment(lib, "urlmon.lib")
  20. ATLAPI_(void) AtlHiMetricToPixel(const SIZEL * lpSizeInHiMetric, LPSIZEL lpSizeInPix);
  21. ATLAPI_(void) AtlPixelToHiMetric(const SIZEL * lpSizeInPix, LPSIZEL lpSizeInHiMetric);
  22. ATLAPI_(HDC) AtlCreateTargetDC(HDC hdc, DVTARGETDEVICE* ptd);
  23. // Include GUIDs for the new stock property dialogs contained in the dll MSStkProp.DLL
  24. #include "msstkppg.h"
  25. #define CLSID_MSStockFont CLSID_StockFontPage
  26. #define CLSID_MSStockColor CLSID_StockColorPage
  27. #define CLSID_MSStockPicture CLSID_StockPicturePage
  28. #ifndef ATL_NO_NAMESPACE
  29. namespace ATL
  30. {
  31. #endif
  32. #pragma pack(push, _ATL_PACKING)
  33. // Forward declarations
  34. //
  35. class ATL_NO_VTABLE CComControlBase;
  36. template <class T> class CComControl;
  37. class CComDispatchDriver;
  38. struct ATL_PROPMAP_ENTRY
  39. {
  40. LPCOLESTR szDesc;
  41. DISPID dispid;
  42. const CLSID* pclsidPropPage;
  43. const IID* piidDispatch;
  44. };
  45. struct ATL_DRAWINFO
  46. {
  47. UINT cbSize;
  48. DWORD dwDrawAspect;
  49. LONG lindex;
  50. DVTARGETDEVICE* ptd;
  51. HDC hicTargetDev;
  52. HDC hdcDraw;
  53. LPCRECTL prcBounds; //Rectangle in which to draw
  54. LPCRECTL prcWBounds; //WindowOrg and Ext if metafile
  55. BOOL bOptimize;
  56. BOOL bZoomed;
  57. BOOL bRectInHimetric;
  58. SIZEL ZoomNum; //ZoomX = ZoomNum.cx/ZoomNum.cy
  59. SIZEL ZoomDen;
  60. };
  61. //////////////////////////////////////////////////////////////////////////////
  62. // CComDispatchDriver / Specialization of CComQIPtr<IDispatch, IID_IDispatch>
  63. class CComDispatchDriver
  64. {
  65. public:
  66. CComDispatchDriver()
  67. {
  68. p = NULL;
  69. }
  70. CComDispatchDriver(IDispatch* lp)
  71. {
  72. if ((p = lp) != NULL)
  73. p->AddRef();
  74. }
  75. CComDispatchDriver(IUnknown* lp)
  76. {
  77. p=NULL;
  78. if (lp != NULL)
  79. lp->QueryInterface(IID_IDispatch, (void **)&p);
  80. }
  81. ~CComDispatchDriver() { if (p) p->Release(); }
  82. void Release() {if (p) p->Release(); p=NULL;}
  83. operator IDispatch*() {return p;}
  84. IDispatch& operator*() {_ASSERTE(p!=NULL); return *p; }
  85. IDispatch** operator&() {_ASSERTE(p==NULL); return &p; }
  86. IDispatch* operator->() {_ASSERTE(p!=NULL); return p; }
  87. IDispatch* operator=(IDispatch* lp){return (IDispatch*)AtlComPtrAssign((IUnknown**)&p, lp);}
  88. IDispatch* operator=(IUnknown* lp)
  89. {
  90. return (IDispatch*)AtlComQIPtrAssign((IUnknown**)&p, lp, IID_IDispatch);
  91. }
  92. BOOL operator!(){return (p == NULL) ? TRUE : FALSE;}
  93. HRESULT GetProperty(DISPID dwDispID, VARIANT* pVar)
  94. {
  95. _ASSERTE(p);
  96. return GetProperty(p, dwDispID, pVar);
  97. }
  98. HRESULT PutProperty(DISPID dwDispID, VARIANT* pVar)
  99. {
  100. _ASSERTE(p);
  101. return PutProperty(p, dwDispID, pVar);
  102. }
  103. static HRESULT GetProperty(IDispatch* pDisp, DISPID dwDispID, VARIANT* pVar);
  104. static HRESULT PutProperty(IDispatch* pDisp, DISPID dwDispID, VARIANT* pVar);
  105. IDispatch* p;
  106. };
  107. //////////////////////////////////////////////////////////////////////////////
  108. // CFirePropNotifyEvent
  109. class CFirePropNotifyEvent
  110. {
  111. public:
  112. static HRESULT FireOnRequestEdit(IUnknown* pUnk, DISPID dispID);
  113. static HRESULT FireOnChanged(IUnknown* pUnk, DISPID dispID);
  114. };
  115. //////////////////////////////////////////////////////////////////////////////
  116. // CFakeFirePropNotifyEvent
  117. class CFakeFirePropNotifyEvent
  118. {
  119. public:
  120. static HRESULT FireOnRequestEdit(IUnknown* /*pUnk*/, DISPID /*dispID*/)
  121. {
  122. return S_OK;
  123. }
  124. static HRESULT FireOnChanged(IUnknown* /*pUnk*/, DISPID /*dispID*/)
  125. {
  126. return S_OK;
  127. }
  128. };
  129. typedef CFakeFirePropNotifyEvent _ATL_PROP_NOTIFY_EVENT_CLASS;
  130. //////////////////////////////////////////////////////////////////////////////
  131. // CComControl
  132. class ATL_NO_VTABLE CComControlBase
  133. {
  134. public:
  135. CComControlBase(HWND& h) : m_hWndCD(h)
  136. {
  137. memset(this, 0, sizeof(CComControlBase));
  138. m_phWndCD = &h;
  139. m_sizeExtent.cx = 2*2540;
  140. m_sizeExtent.cy = 2*2540;
  141. m_sizeNatural = m_sizeExtent;
  142. }
  143. ~CComControlBase()
  144. {
  145. if (m_hWndCD != NULL)
  146. ::DestroyWindow(m_hWndCD);
  147. ATLTRACE(_T("Control Destroyed\n"));
  148. }
  149. // methods
  150. public:
  151. // Control helper functions can go here
  152. // non-virtuals only please
  153. void SetDirty(BOOL bDirty)
  154. {
  155. m_bRequiresSave = bDirty;
  156. }
  157. BOOL GetDirty()
  158. {
  159. return m_bRequiresSave ? TRUE : FALSE;
  160. }
  161. void GetZoomInfo(ATL_DRAWINFO& di);
  162. HRESULT SendOnRename(IMoniker *pmk)
  163. {
  164. HRESULT hRes = S_OK;
  165. if (m_spOleAdviseHolder)
  166. hRes = m_spOleAdviseHolder->SendOnRename(pmk);
  167. return hRes;
  168. }
  169. HRESULT SendOnSave()
  170. {
  171. HRESULT hRes = S_OK;
  172. if (m_spOleAdviseHolder)
  173. hRes = m_spOleAdviseHolder->SendOnSave();
  174. return hRes;
  175. }
  176. HRESULT SendOnClose()
  177. {
  178. HRESULT hRes = S_OK;
  179. if (m_spOleAdviseHolder)
  180. hRes = m_spOleAdviseHolder->SendOnClose();
  181. return hRes;
  182. }
  183. HRESULT SendOnDataChange(DWORD advf = 0);
  184. HRESULT SendOnViewChange(DWORD dwAspect, LONG lindex = -1)
  185. {
  186. if (m_spAdviseSink)
  187. m_spAdviseSink->OnViewChange(dwAspect, lindex);
  188. return S_OK;
  189. }
  190. LRESULT OnSetFocus(UINT /* nMsg */, WPARAM /* wParam */, LPARAM /* lParam */, BOOL& /* bHandled */)
  191. {
  192. CComQIPtr <IOleControlSite, &IID_IOleControlSite> spSite(m_spClientSite);
  193. if (m_bInPlaceActive && spSite)
  194. spSite->OnFocus(TRUE);
  195. return 0;
  196. }
  197. LRESULT OnKillFocus(UINT /* nMsg */, WPARAM /* wParam */, LPARAM /* lParam */, BOOL& /* bHandled */)
  198. {
  199. CComQIPtr <IOleControlSite, &IID_IOleControlSite> spSite(m_spClientSite);
  200. if (m_bInPlaceActive && spSite)
  201. spSite->OnFocus(FALSE);
  202. return 0;
  203. }
  204. LRESULT OnGetDlgCode(UINT /* nMsg */, WPARAM /* wParam */, LPARAM /* lParam */, BOOL& /* bHandled */)
  205. {
  206. return 0;
  207. }
  208. HRESULT GetAmbientProperty(DISPID dispid, VARIANT& var)
  209. {
  210. HRESULT hRes = E_FAIL;
  211. if (m_spAmbientDispatch.p != NULL)
  212. hRes = m_spAmbientDispatch.GetProperty(dispid, &var);
  213. return hRes;
  214. }
  215. HRESULT GetAmbientAppearance(short& nAppearance)
  216. {
  217. CComVariant var;
  218. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_APPEARANCE, var);
  219. _ASSERTE(var.vt == VT_I2 || FAILED(hRes));
  220. nAppearance = var.iVal;
  221. return hRes;
  222. }
  223. HRESULT GetAmbientBackColor(OLE_COLOR& BackColor)
  224. {
  225. CComVariant var;
  226. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_BACKCOLOR, var);
  227. _ASSERTE(var.vt == VT_I4 || FAILED(hRes));
  228. BackColor = var.lVal;
  229. return hRes;
  230. }
  231. HRESULT GetAmbientDisplayName(BSTR& bstrDiaplayName)
  232. {
  233. CComVariant var;
  234. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_DISPLAYNAME, var);
  235. _ASSERTE(var.vt == VT_BSTR || FAILED(hRes));
  236. bstrDiaplayName = var.bstrVal;
  237. return hRes;
  238. }
  239. HRESULT GetAmbientFont(IFont** ppFont)
  240. {
  241. // caller MUST Release the font!
  242. if (ppFont == NULL)
  243. return E_POINTER;
  244. CComVariant var;
  245. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_FONT, var);
  246. _ASSERTE((var.vt == VT_UNKNOWN || var.vt == VT_DISPATCH) || FAILED(hRes));
  247. if (SUCCEEDED(hRes) && var.pdispVal)
  248. {
  249. if (var.vt == VT_UNKNOWN || var.vt == VT_DISPATCH)
  250. hRes = var.pdispVal->QueryInterface(IID_IFont, (void**)ppFont);
  251. else
  252. hRes = DISP_E_BADVARTYPE;
  253. }
  254. return hRes;
  255. }
  256. HRESULT GetAmbientForeColor(OLE_COLOR& ForeColor)
  257. {
  258. CComVariant var;
  259. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_FORECOLOR, var);
  260. _ASSERTE(var.vt == VT_I4 || FAILED(hRes));
  261. ForeColor = var.lVal;
  262. return hRes;
  263. }
  264. HRESULT GetAmbientLocaleID(LCID& lcid)
  265. {
  266. CComVariant var;
  267. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_LOCALEID, var);
  268. _ASSERTE(var.vt == VT_I4 || FAILED(hRes));
  269. lcid = var.lVal;
  270. return hRes;
  271. }
  272. HRESULT GetAmbientScaleUnits(BSTR& bstrScaleUnits)
  273. {
  274. CComVariant var;
  275. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_SCALEUNITS, var);
  276. _ASSERTE(var.vt == VT_BSTR || FAILED(hRes));
  277. bstrScaleUnits = var.bstrVal;
  278. return hRes;
  279. }
  280. HRESULT GetAmbientTextAlign(short& nTextAlign)
  281. {
  282. CComVariant var;
  283. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_TEXTALIGN, var);
  284. _ASSERTE(var.vt == VT_I2 || FAILED(hRes));
  285. nTextAlign = var.iVal;
  286. return hRes;
  287. }
  288. HRESULT GetAmbientUserMode(BOOL& bUserMode)
  289. {
  290. CComVariant var;
  291. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_USERMODE, var);
  292. _ASSERTE(var.vt == VT_BOOL || FAILED(hRes));
  293. bUserMode = var.boolVal;
  294. return hRes;
  295. }
  296. HRESULT GetAmbientUIDead(BOOL& bUIDead)
  297. {
  298. CComVariant var;
  299. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_UIDEAD, var);
  300. _ASSERTE(var.vt == VT_BOOL || FAILED(hRes));
  301. bUIDead = var.boolVal;
  302. return hRes;
  303. }
  304. HRESULT GetAmbientShowGrabHandles(BOOL& bShowGrabHandles)
  305. {
  306. CComVariant var;
  307. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_SHOWGRABHANDLES, var);
  308. _ASSERTE(var.vt == VT_BOOL || FAILED(hRes));
  309. bShowGrabHandles = var.boolVal;
  310. return hRes;
  311. }
  312. HRESULT GetAmbientShowHatching(BOOL& bShowHatching)
  313. {
  314. CComVariant var;
  315. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_SHOWHATCHING, var);
  316. _ASSERTE(var.vt == VT_BOOL || FAILED(hRes));
  317. bShowHatching = var.boolVal;
  318. return hRes;
  319. }
  320. HRESULT GetAmbientMessageReflect(BOOL& bMessageReflect)
  321. {
  322. CComVariant var;
  323. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_MESSAGEREFLECT, var);
  324. _ASSERTE(var.vt == VT_BOOL || FAILED(hRes));
  325. bMessageReflect = var.boolVal;
  326. return hRes;
  327. }
  328. HRESULT GetAmbientAutoClip(BOOL& bAutoClip)
  329. {
  330. CComVariant var;
  331. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_AUTOCLIP, var);
  332. _ASSERTE(var.vt == VT_BOOL || FAILED(hRes));
  333. bAutoClip = var.boolVal;
  334. return hRes;
  335. }
  336. HRESULT GetAmbientDisplayAsDefault(BOOL& bDisplaysDefault)
  337. {
  338. CComVariant var;
  339. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_DISPLAYASDEFAULT, var);
  340. _ASSERTE(var.vt == VT_BOOL || FAILED(hRes));
  341. bDisplaysDefault = var.boolVal;
  342. return hRes;
  343. }
  344. HRESULT GetAmbientSupportsMnemonics(BOOL& bSupportMnemonics)
  345. {
  346. CComVariant var;
  347. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_SUPPORTSMNEMONICS, var);
  348. _ASSERTE(var.vt == VT_BOOL || FAILED(hRes));
  349. bSupportMnemonics = var.boolVal;
  350. return hRes;
  351. }
  352. HRESULT GetAmbientPalette(HPALETTE& hPalette)
  353. {
  354. CComVariant var;
  355. HRESULT hRes = GetAmbientProperty(DISPID_AMBIENT_PALETTE, var);
  356. _ASSERTE(var.vt == VT_INT_PTR || FAILED(hRes));
  357. hPalette = reinterpret_cast<HPALETTE>(var.byref);
  358. return hRes;
  359. }
  360. BOOL DoesVerbUIActivate(LONG iVerb)
  361. {
  362. BOOL b = FALSE;
  363. switch (iVerb)
  364. {
  365. case OLEIVERB_UIACTIVATE:
  366. case OLEIVERB_PRIMARY:
  367. b = TRUE;
  368. break;
  369. }
  370. // if no ambient dispatch then in old style OLE container
  371. if (DoesVerbActivate(iVerb) && m_spAmbientDispatch.p == NULL)
  372. b = TRUE;
  373. return b;
  374. }
  375. BOOL DoesVerbActivate(LONG iVerb)
  376. {
  377. BOOL b = FALSE;
  378. switch (iVerb)
  379. {
  380. case OLEIVERB_UIACTIVATE:
  381. case OLEIVERB_PRIMARY:
  382. case OLEIVERB_SHOW:
  383. case OLEIVERB_INPLACEACTIVATE:
  384. b = TRUE;
  385. break;
  386. }
  387. return b;
  388. }
  389. BOOL SetControlFocus(BOOL bGrab);
  390. HRESULT IQuickActivate_QuickActivate(QACONTAINER *pQACont,
  391. QACONTROL *pQACtrl);
  392. HRESULT IPersistPropertyBag_Load(LPPROPERTYBAG pPropBag,
  393. LPERRORLOG pErrorLog, ATL_PROPMAP_ENTRY* pMap);
  394. HRESULT IPersistPropertyBag_Save(LPPROPERTYBAG pPropBag,
  395. BOOL fClearDirty, BOOL fSaveAllProperties, ATL_PROPMAP_ENTRY* pMap);
  396. HRESULT ISpecifyPropertyPages_GetPages(CAUUID* pPages,
  397. ATL_PROPMAP_ENTRY* pMap);
  398. HRESULT DoVerbProperties(LPCRECT /* prcPosRect */, HWND hwndParent);
  399. HRESULT InPlaceActivate(LONG iVerb, const RECT* prcPosRect = NULL);
  400. HRESULT IPersistStreamInit_Load(LPSTREAM pStm, ATL_PROPMAP_ENTRY* pMap);
  401. HRESULT IPersistStreamInit_Save(LPSTREAM pStm, BOOL /* fClearDirty */,
  402. ATL_PROPMAP_ENTRY* pMap);
  403. HRESULT IOleObject_SetClientSite(IOleClientSite *pClientSite);
  404. HRESULT IOleObject_GetClientSite(IOleClientSite **ppClientSite);
  405. HRESULT IOleObject_Advise(IAdviseSink *pAdvSink, DWORD *pdwConnection);
  406. HRESULT IOleObject_Close(DWORD dwSaveOption);
  407. HRESULT IOleObject_SetExtent(DWORD dwDrawAspect, SIZEL *psizel);
  408. HRESULT IOleInPlaceObject_InPlaceDeactivate(void);
  409. HRESULT IOleInPlaceObject_UIDeactivate(void);
  410. HRESULT IOleInPlaceObject_SetObjectRects(LPCRECT prcPos,LPCRECT prcClip);
  411. HRESULT IViewObject_Draw(DWORD dwDrawAspect, LONG lindex, void *pvAspect,
  412. DVTARGETDEVICE *ptd, HDC hicTargetDev, HDC hdcDraw,
  413. LPCRECTL prcBounds, LPCRECTL prcWBounds);
  414. HRESULT IDataObject_GetData(FORMATETC *pformatetcIn, STGMEDIUM *pmedium);
  415. HRESULT FireViewChange();
  416. LRESULT OnPaint(UINT /* nMsg */, WPARAM /* wParam */, LPARAM /* lParam */,
  417. BOOL& /* lResult */);
  418. virtual HWND CreateControlWindow(HWND hWndParent, RECT& rcPos) = 0;
  419. virtual HRESULT ControlQueryInterface(const IID& iid, void** ppv) = 0;
  420. virtual HRESULT OnDrawAdvanced(ATL_DRAWINFO& di);
  421. virtual HRESULT OnDraw(ATL_DRAWINFO& di)
  422. {
  423. return S_OK;
  424. }
  425. // Attributes
  426. public:
  427. CComPtr<IOleInPlaceSiteWindowless> m_spInPlaceSite;
  428. CComPtr<IDataAdviseHolder> m_spDataAdviseHolder;
  429. CComPtr<IOleAdviseHolder> m_spOleAdviseHolder;
  430. CComPtr<IOleClientSite> m_spClientSite;
  431. CComPtr<IAdviseSink> m_spAdviseSink;
  432. CComDispatchDriver m_spAmbientDispatch;
  433. SIZE m_sizeNatural; //unscaled size in himetric
  434. SIZE m_sizeExtent; //current extents in himetric
  435. RECT m_rcPos; // position in pixels
  436. union
  437. {
  438. HWND& m_hWndCD;
  439. HWND* m_phWndCD;
  440. };
  441. union
  442. {
  443. // m_nFreezeEvents is the only one actually used
  444. int m_nFreezeEvents; // count of freezes versus thaws
  445. // These are here to make stock properties work
  446. IPictureDisp* m_pMouseIcon;
  447. IPictureDisp* m_pPicture;
  448. IFontDisp* m_pFont;
  449. OLE_COLOR m_clrBackColor;
  450. OLE_COLOR m_clrBorderColor;
  451. OLE_COLOR m_clrFillColor;
  452. OLE_COLOR m_clrForeColor;
  453. BSTR m_bstrText;
  454. BSTR m_bstrCaption;
  455. BOOL m_bValid;
  456. BOOL m_bTabStop;
  457. BOOL m_bBorderVisible;
  458. BOOL m_bEnabled;
  459. long m_nBackStyle;
  460. long m_nBorderStyle;
  461. long m_nBorderWidth;
  462. long m_nDrawMode;
  463. long m_nDrawStyle;
  464. long m_nDrawWidth;
  465. long m_nFillStyle;
  466. long m_nAppearance;
  467. long m_nMousePointer;
  468. long m_nReadyState;
  469. };
  470. unsigned m_bNegotiatedWnd:1;
  471. unsigned m_bWndLess:1;
  472. unsigned m_bInPlaceActive:1;
  473. unsigned m_bUIActive:1;
  474. unsigned m_bUsingWindowRgn:1;
  475. unsigned m_bInPlaceSiteEx:1;
  476. unsigned m_bWindowOnly:1;
  477. unsigned m_bRequiresSave:1;
  478. unsigned m_bWasOnceWindowless:1;
  479. unsigned m_bAutoSize:1; //SetExtent fails if size doesn't match existing
  480. unsigned m_bRecomposeOnResize:1; //implies OLEMISC_RECOMPOSEONRESIZE
  481. unsigned m_bResizeNatural:1; //resize natural extent on SetExtent
  482. unsigned m_bDrawFromNatural:1; //instead of m_sizeExtent
  483. unsigned m_bDrawGetDataInHimetric:1; //instead of pixels
  484. };
  485. template <class T>
  486. class ATL_NO_VTABLE CComControl : public CComControlBase, public CWindowImpl<T>
  487. {
  488. public:
  489. CComControl() : CComControlBase(m_hWnd) {}
  490. HRESULT FireOnRequestEdit(DISPID dispID)
  491. {
  492. T* pT = static_cast<T*>(this);
  493. return T::__ATL_PROP_NOTIFY_EVENT_CLASS::FireOnRequestEdit(pT->GetUnknown(), dispID);
  494. }
  495. HRESULT FireOnChanged(DISPID dispID)
  496. {
  497. T* pT = static_cast<T*>(this);
  498. return T::__ATL_PROP_NOTIFY_EVENT_CLASS::FireOnChanged(pT->GetUnknown(), dispID);
  499. }
  500. virtual HRESULT ControlQueryInterface(const IID& iid, void** ppv)
  501. {
  502. T* pT = static_cast<T*>(this);
  503. return pT->_InternalQueryInterface(iid, ppv);
  504. }
  505. virtual HWND CreateControlWindow(HWND hWndParent, RECT& rcPos)
  506. {
  507. T* pT = static_cast<T*>(this);
  508. return pT->Create(hWndParent, rcPos);
  509. }
  510. };
  511. // Forward declarations
  512. //
  513. template <class T> class IPersistImpl;
  514. template <class T> class IPersistStreamInitImpl;
  515. template <class T> class IPersistStorageImpl;
  516. template <class T> class IPersistPropertyBagImpl;
  517. template <class T> class IOleControlImpl;
  518. template <class T> class IRunnableObjectImpl;
  519. template <class T> class IQuickActivateImpl;
  520. template <class T> class IOleObjectImpl;
  521. template <class T> class IPropertyPageImpl;
  522. template <class T> class IPropertyPage2Impl;
  523. template <class T> class IPerPropertyBrowsingImpl;
  524. template <class T> class IViewObjectExImpl;
  525. template <class T> class IOleWindowImpl;
  526. template <class T> class ISpecifyPropertyPagesImpl;
  527. template <class T> class IPointerInactiveImpl;
  528. template <class T, class CDV> class IPropertyNotifySinkCP;
  529. template <class T> class IBindStatusCallbackImpl;
  530. template <class T> class CBindStatusCallback;
  531. //////////////////////////////////////////////////////////////////////////////
  532. // IPersistImpl
  533. template <class T>
  534. class ATL_NO_VTABLE IPersistImpl
  535. {
  536. public:
  537. // IUnknown
  538. //
  539. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  540. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IPersistImpl)
  541. // IPersist
  542. STDMETHOD(GetClassID)(CLSID *pClassID)
  543. {
  544. ATLTRACE(_T("IPersistImpl::GetClassID\n"));
  545. T* pT = static_cast<T*>(this);
  546. *pClassID = pT->GetObjectCLSID();
  547. return S_OK;
  548. }
  549. };
  550. #define BEGIN_PROPERTY_MAP(theClass) \
  551. typedef _ATL_PROP_NOTIFY_EVENT_CLASS __ATL_PROP_NOTIFY_EVENT_CLASS; \
  552. static ATL_PROPMAP_ENTRY* GetPropertyMap()\
  553. {\
  554. static ATL_PROPMAP_ENTRY pPropMap[] = \
  555. {
  556. #define PROP_ENTRY(szDesc, dispid, clsid) \
  557. {OLESTR(szDesc), dispid, &clsid, &IID_IDispatch},
  558. #define PROP_ENTRY_EX(szDesc, dispid, clsid, iidDispatch) \
  559. {OLESTR(szDesc), dispid, &clsid, &iidDispatch},
  560. #define PROP_PAGE(clsid) \
  561. {NULL, NULL, &clsid, &IID_NULL},
  562. #define END_PROPERTY_MAP() \
  563. {NULL, 0, NULL, &IID_NULL} \
  564. }; \
  565. return pPropMap; \
  566. }
  567. //////////////////////////////////////////////////////////////////////////////
  568. // IPersistStreamInitImpl
  569. template <class T>
  570. class ATL_NO_VTABLE IPersistStreamInitImpl
  571. {
  572. public:
  573. // IUnknown
  574. //
  575. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  576. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IPersistStreamInitImpl)
  577. #if _MSC_VER >= 1200
  578. #pragma warning( push )
  579. #pragma warning( disable: 4189 )
  580. #endif
  581. // IPersist
  582. STDMETHOD(GetClassID)(CLSID *pClassID)
  583. {
  584. ATLTRACE(_T("IPersistStreamInitImpl::GetClassID\n"));
  585. T* pT = static_cast<T*>(this);
  586. *pClassID = pT->GetObjectCLSID();
  587. return S_OK;
  588. }
  589. #if _MSC_VER >= 1200
  590. #pragma warning( pop )
  591. #endif
  592. // IPersistStream
  593. STDMETHOD(IsDirty)()
  594. {
  595. ATLTRACE(_T("IPersistStreamInitImpl::IsDirty\n"));
  596. T* pT = static_cast<T*>(this);
  597. return (pT->m_bRequiresSave) ? S_OK : S_FALSE;
  598. }
  599. STDMETHOD(Load)(LPSTREAM pStm)
  600. {
  601. ATLTRACE(_T("IPersistStreamInitImpl::Load\n"));
  602. T* pT = static_cast<T*>(this);
  603. return pT->IPersistStreamInit_Load(pStm, T::GetPropertyMap());
  604. }
  605. STDMETHOD(Save)(LPSTREAM pStm, BOOL fClearDirty)
  606. {
  607. T* pT = static_cast<T*>(this);
  608. ATLTRACE(_T("IPersistStreamInitImpl::Save\n"));
  609. return pT->IPersistStreamInit_Save(pStm, fClearDirty, T::GetPropertyMap());
  610. }
  611. STDMETHOD(GetSizeMax)(ULARGE_INTEGER FAR* /* pcbSize */)
  612. {
  613. ATLTRACENOTIMPL(_T("IPersistStreamInitImpl::GetSizeMax"));
  614. }
  615. // IPersistStreamInit
  616. STDMETHOD(InitNew)()
  617. {
  618. T* pT = static_cast<T*>(this);
  619. ATLTRACE(_T("IPersistStreamInitImpl::InitNew\n"));
  620. pT->SendOnDataChange();
  621. return S_OK;
  622. }
  623. };
  624. //////////////////////////////////////////////////////////////////////////////
  625. // IPersistStorageImpl
  626. template <class T>
  627. class ATL_NO_VTABLE IPersistStorageImpl
  628. {
  629. public:
  630. // IUnknown
  631. //
  632. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  633. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IPersistStorageImpl)
  634. // IPersist
  635. STDMETHOD(GetClassID)(CLSID *pClassID)
  636. {
  637. ATLTRACE(_T("IPersistStorageImpl::GetClassID\n"));
  638. T* pT = static_cast<T*>(this);
  639. *pClassID = pT->GetObjectCLSID();
  640. return S_OK;
  641. }
  642. // IPersistStorage
  643. STDMETHOD(IsDirty)(void)
  644. {
  645. ATLTRACE(_T("IPersistStorageImpl::IsDirty\n"));
  646. T* pT = static_cast<T*>(this);
  647. CComPtr<IPersistStreamInit> p;
  648. p.p = IPSI_GetIPersistStreamInit();
  649. return (p != NULL) ? p->IsDirty() : E_FAIL;
  650. }
  651. STDMETHOD(InitNew)(IStorage*)
  652. {
  653. ATLTRACE(_T("IPersistStorageImpl::InitNew\n"));
  654. T* pT = static_cast<T*>(this);
  655. CComPtr<IPersistStreamInit> p;
  656. p.p = IPSI_GetIPersistStreamInit();
  657. return (p != NULL) ? p->InitNew() : E_FAIL;
  658. }
  659. STDMETHOD(Load)(IStorage* pStorage)
  660. {
  661. ATLTRACE(_T("IPersistStorageImpl::Load\n"));
  662. T* pT = static_cast<T*>(this);
  663. CComPtr<IPersistStreamInit> p;
  664. p.p = IPSI_GetIPersistStreamInit();
  665. HRESULT hr = E_FAIL;
  666. if (p != NULL)
  667. {
  668. CComPtr<IStream> spStream;
  669. hr = pStorage->OpenStream(OLESTR("Contents"), NULL,
  670. STGM_DIRECT | STGM_SHARE_EXCLUSIVE, 0, &spStream);
  671. if (SUCCEEDED(hr))
  672. hr = p->Load(spStream);
  673. }
  674. return hr;
  675. }
  676. STDMETHOD(Save)(IStorage* pStorage, BOOL fSameAsLoad)
  677. {
  678. ATLTRACE(_T("IPersistStorageImpl::Save\n"));
  679. T* pT = static_cast<T*>(this);
  680. CComPtr<IPersistStreamInit> p;
  681. p.p = IPSI_GetIPersistStreamInit();
  682. HRESULT hr = E_FAIL;
  683. if (p != NULL)
  684. {
  685. CComPtr<IStream> spStream;
  686. static LPCOLESTR vszContents = OLESTR("Contents");
  687. hr = pStorage->CreateStream(vszContents,
  688. STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE,
  689. 0, 0, &spStream);
  690. if (SUCCEEDED(hr))
  691. hr = p->Save(spStream, fSameAsLoad);
  692. }
  693. return hr;
  694. }
  695. STDMETHOD(SaveCompleted)(IStorage* /* pStorage */)
  696. {
  697. ATLTRACE(_T("IPersistStorageImpl::SaveCompleted\n"));
  698. return S_OK;
  699. }
  700. STDMETHOD(HandsOffStorage)(void)
  701. {
  702. ATLTRACE(_T("IPersistStorageImpl::HandsOffStorage\n"));
  703. return S_OK;
  704. }
  705. private:
  706. IPersistStreamInit* IPSI_GetIPersistStreamInit();
  707. };
  708. template <class T>
  709. IPersistStreamInit* IPersistStorageImpl<T>::IPSI_GetIPersistStreamInit()
  710. {
  711. T* pT = static_cast<T*>(this);
  712. IPersistStreamInit* p;
  713. if (FAILED(pT->GetUnknown()->QueryInterface(IID_IPersistStreamInit, (void**)&p)))
  714. pT->_InternalQueryInterface(IID_IPersistStreamInit, (void**)&p);
  715. return p;
  716. }
  717. //////////////////////////////////////////////////////////////////////////////
  718. // IPersistPropertyBagImpl
  719. template <class T>
  720. class ATL_NO_VTABLE IPersistPropertyBagImpl
  721. {
  722. public:
  723. // IUnknown
  724. //
  725. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  726. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IPersistPropertyBagImpl)
  727. // IPersist
  728. STDMETHOD(GetClassID)(CLSID *pClassID)
  729. {
  730. ATLTRACE(_T("IPersistPropertyBagImpl::GetClassID\n"));
  731. T* pT = static_cast<T*>(this);
  732. *pClassID = pT->GetObjectCLSID();
  733. return S_OK;
  734. }
  735. // IPersistPropertyBag
  736. //
  737. STDMETHOD(InitNew)()
  738. {
  739. ATLTRACE(_T("IPersistPropertyBagImpl::InitNew\n"));
  740. return S_OK;
  741. }
  742. STDMETHOD(Load)(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog)
  743. {
  744. ATLTRACE(_T("IPersistPropertyBagImpl::Load\n"));
  745. T* pT = static_cast<T*>(this);
  746. ATL_PROPMAP_ENTRY* pMap = T::GetPropertyMap();
  747. _ASSERTE(pMap != NULL);
  748. return pT->IPersistPropertyBag_Load(pPropBag, pErrorLog, pMap);
  749. }
  750. STDMETHOD(Save)(LPPROPERTYBAG pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties)
  751. {
  752. ATLTRACE(_T("IPersistPropertyBagImpl::Save\n"));
  753. T* pT = static_cast<T*>(this);
  754. ATL_PROPMAP_ENTRY* pMap = T::GetPropertyMap();
  755. _ASSERTE(pMap != NULL);
  756. return pT->IPersistPropertyBag_Save(pPropBag, fClearDirty, fSaveAllProperties, pMap);
  757. }
  758. };
  759. //////////////////////////////////////////////////////////////////////////////
  760. // IOleControlImpl
  761. template <class T>
  762. class ATL_NO_VTABLE IOleControlImpl
  763. {
  764. public:
  765. // IUnknown
  766. //
  767. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  768. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IOleControlImpl)
  769. // IOleControl methods
  770. //
  771. STDMETHOD(GetControlInfo)(LPCONTROLINFO /* pCI */)
  772. {
  773. ATLTRACENOTIMPL(_T("IOleControlImpl::GetControlInfo"));
  774. }
  775. STDMETHOD(OnMnemonic)(LPMSG /* pMsg */)
  776. {
  777. ATLTRACENOTIMPL(_T("IOleControlImpl::OnMnemonic"));
  778. }
  779. STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
  780. {
  781. dispid;
  782. ATLTRACE(_T("IOleControlImpl::OnAmbientPropertyChange\n"));
  783. ATLTRACE(_T(" -- DISPID = %d (%d)\n"), dispid);
  784. return S_OK;
  785. }
  786. STDMETHOD(FreezeEvents)(BOOL bFreeze)
  787. {
  788. T* pT = static_cast<T*>(this);
  789. ATLTRACE(_T("IOleControlImpl::FreezeEvents\n"));
  790. if (bFreeze)
  791. pT->m_nFreezeEvents++;
  792. else
  793. pT->m_nFreezeEvents--;
  794. return S_OK;
  795. }
  796. };
  797. //////////////////////////////////////////////////////////////////////////////
  798. // IQuickActivateImpl
  799. template <class T>
  800. class ATL_NO_VTABLE IQuickActivateImpl
  801. {
  802. public:
  803. // IUnknown
  804. //
  805. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  806. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IQuickActivateImpl)
  807. // IQuickActivate
  808. //
  809. STDMETHOD(QuickActivate)(QACONTAINER *pQACont, QACONTROL *pQACtrl)
  810. {
  811. T* pT = static_cast<T*>(this);
  812. ATLTRACE(_T("IQuickActivateImpl::QuickActivate\n"));
  813. return pT->IQuickActivate_QuickActivate(pQACont, pQACtrl);
  814. }
  815. STDMETHOD(SetContentExtent)(LPSIZEL pSize)
  816. {
  817. T* pT = static_cast<T*>(this);
  818. ATLTRACE(_T("IQuickActivateImpl::SetContentExtent\n"));
  819. return pT->IOleObjectImpl<T>::SetExtent(DVASPECT_CONTENT, pSize);
  820. }
  821. STDMETHOD(GetContentExtent)(LPSIZEL pSize)
  822. {
  823. T* pT = static_cast<T*>(this);
  824. ATLTRACE(_T("IQuickActivateImpl::GetContentExtent\n"));
  825. return pT->IOleObjectImpl<T>::GetExtent(DVASPECT_CONTENT, pSize);
  826. }
  827. };
  828. //////////////////////////////////////////////////////////////////////////////
  829. // IOleObjectImpl
  830. template <class T>
  831. class ATL_NO_VTABLE IOleObjectImpl
  832. {
  833. public:
  834. // IUnknown
  835. //
  836. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  837. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IOleObjectImpl)
  838. // IOleObject
  839. //
  840. STDMETHOD(SetClientSite)(IOleClientSite *pClientSite)
  841. {
  842. T* pT = static_cast<T*>(this);
  843. ATLTRACE(_T("IOleObjectImpl::SetClientSite\n"));
  844. return pT->IOleObject_SetClientSite(pClientSite);
  845. }
  846. STDMETHOD(GetClientSite)(IOleClientSite **ppClientSite)
  847. {
  848. T* pT = static_cast<T*>(this);
  849. ATLTRACE(_T("IOleObjectImpl::GetClientSite\n"));
  850. return pT->IOleObject_GetClientSite(ppClientSite);
  851. }
  852. STDMETHOD(SetHostNames)(LPCOLESTR /* szContainerApp */, LPCOLESTR /* szContainerObj */)
  853. {
  854. ATLTRACE(_T("IOleObjectImpl::SetHostNames\n"));
  855. return S_OK;
  856. }
  857. STDMETHOD(Close)(DWORD dwSaveOption)
  858. {
  859. T* pT = static_cast<T*>(this);
  860. ATLTRACE(_T("IOleObjectImpl::Close\n"));
  861. return pT->IOleObject_Close(dwSaveOption);
  862. }
  863. STDMETHOD(SetMoniker)(DWORD /* dwWhichMoniker */, IMoniker* /* pmk */)
  864. {
  865. ATLTRACENOTIMPL(_T("IOleObjectImpl::SetMoniker"));
  866. }
  867. STDMETHOD(GetMoniker)(DWORD /* dwAssign */, DWORD /* dwWhichMoniker */, IMoniker** /* ppmk */)
  868. {
  869. ATLTRACENOTIMPL(_T("IOleObjectImpl::GetMoniker"));
  870. }
  871. STDMETHOD(InitFromData)(IDataObject* /* pDataObject */, BOOL /* fCreation */, DWORD /* dwReserved */)
  872. {
  873. ATLTRACENOTIMPL(_T("IOleObjectImpl::InitFromData"));
  874. }
  875. STDMETHOD(GetClipboardData)(DWORD /* dwReserved */, IDataObject** /* ppDataObject */)
  876. {
  877. ATLTRACENOTIMPL(_T("IOleObjectImpl::GetClipboardData"));
  878. }
  879. // Helpers for DoVerb - Over-rideable in user class
  880. HRESULT DoVerbPrimary(LPCRECT prcPosRect, HWND hwndParent)
  881. {
  882. T* pT = static_cast<T*>(this);
  883. BOOL bDesignMode = FALSE;
  884. CComVariant var;
  885. // if container doesn't support this property
  886. // don't allow design mode
  887. HRESULT hRes = pT->GetAmbientProperty(DISPID_AMBIENT_USERMODE, var);
  888. if (SUCCEEDED(hRes) && var.vt == VT_BOOL && !var.boolVal)
  889. bDesignMode = TRUE;
  890. if (bDesignMode)
  891. return pT->DoVerbProperties(prcPosRect, hwndParent);
  892. else
  893. return pT->DoVerbInPlaceActivate(prcPosRect, hwndParent);
  894. }
  895. HRESULT DoVerbShow(LPCRECT prcPosRect, HWND /* hwndParent */)
  896. {
  897. T* pT = static_cast<T*>(this);
  898. return pT->InPlaceActivate(OLEIVERB_SHOW, prcPosRect);
  899. }
  900. HRESULT DoVerbInPlaceActivate(LPCRECT prcPosRect, HWND /* hwndParent */)
  901. {
  902. T* pT = static_cast<T*>(this);
  903. return pT->InPlaceActivate(OLEIVERB_INPLACEACTIVATE, prcPosRect);
  904. }
  905. HRESULT DoVerbUIActivate(LPCRECT prcPosRect, HWND /* hwndParent */)
  906. {
  907. T* pT = static_cast<T*>(this);
  908. return pT->InPlaceActivate(OLEIVERB_UIACTIVATE, prcPosRect);
  909. }
  910. HRESULT DoVerbHide(LPCRECT /* prcPosRect */, HWND /* hwndParent */)
  911. {
  912. T* pT = static_cast<T*>(this);
  913. pT->UIDeactivate();
  914. if (pT->m_hWnd)
  915. pT->ShowWindow(SW_HIDE);
  916. return S_OK;
  917. }
  918. HRESULT DoVerbOpen(LPCRECT /* prcPosRect */, HWND /* hwndParent */)
  919. {
  920. return S_OK;
  921. }
  922. HRESULT DoVerbDiscardUndo(LPCRECT /* prcPosRect */, HWND /* hwndParent */)
  923. {
  924. return S_OK;
  925. }
  926. STDMETHOD(DoVerb)(LONG iVerb, LPMSG /* lpmsg */, IOleClientSite* /* pActiveSite */, LONG /* lindex */,
  927. HWND hwndParent, LPCRECT lprcPosRect)
  928. {
  929. T* pT = static_cast<T*>(this);
  930. ATLTRACE(_T("IOleObjectImpl::DoVerb\n"));
  931. _ASSERTE(pT->m_spClientSite);
  932. HRESULT hr = E_NOTIMPL;
  933. switch (iVerb)
  934. {
  935. case OLEIVERB_PRIMARY:
  936. hr = pT->DoVerbPrimary(lprcPosRect, hwndParent);
  937. break;
  938. case OLEIVERB_SHOW:
  939. hr = pT->DoVerbShow(lprcPosRect, hwndParent);
  940. break;
  941. case OLEIVERB_INPLACEACTIVATE:
  942. hr = pT->DoVerbInPlaceActivate(lprcPosRect, hwndParent);
  943. break;
  944. case OLEIVERB_UIACTIVATE:
  945. hr = pT->DoVerbUIActivate(lprcPosRect, hwndParent);
  946. break;
  947. case OLEIVERB_HIDE:
  948. hr = pT->DoVerbHide(lprcPosRect, hwndParent);
  949. break;
  950. case OLEIVERB_OPEN:
  951. hr = pT->DoVerbOpen(lprcPosRect, hwndParent);
  952. break;
  953. case OLEIVERB_DISCARDUNDOSTATE:
  954. hr = pT->DoVerbDiscardUndo(lprcPosRect, hwndParent);
  955. break;
  956. case OLEIVERB_PROPERTIES:
  957. hr = pT->DoVerbProperties(lprcPosRect, hwndParent);
  958. }
  959. return hr;
  960. }
  961. STDMETHOD(EnumVerbs)(IEnumOLEVERB **ppEnumOleVerb)
  962. {
  963. ATLTRACE(_T("IOleObjectImpl::EnumVerbs\n"));
  964. _ASSERTE(ppEnumOleVerb);
  965. if (!ppEnumOleVerb)
  966. return E_POINTER;
  967. return OleRegEnumVerbs(T::GetObjectCLSID(), ppEnumOleVerb);
  968. }
  969. STDMETHOD(Update)(void)
  970. {
  971. ATLTRACE(_T("IOleObjectImpl::Update\n"));
  972. return S_OK;
  973. }
  974. STDMETHOD(IsUpToDate)(void)
  975. {
  976. ATLTRACE(_T("IOleObjectImpl::IsUpToDate\n"));
  977. return S_OK;
  978. }
  979. STDMETHOD(GetUserClassID)(CLSID *pClsid)
  980. {
  981. ATLTRACE(_T("IOleObjectImpl::GetUserClassID\n"));
  982. _ASSERTE(pClsid);
  983. if (!pClsid)
  984. return E_POINTER;
  985. *pClsid = T::GetObjectCLSID();
  986. return S_OK;
  987. }
  988. STDMETHOD(GetUserType)(DWORD dwFormOfType, LPOLESTR *pszUserType)
  989. {
  990. ATLTRACE(_T("IOleObjectImpl::GetUserType\n"));
  991. return OleRegGetUserType(T::GetObjectCLSID(), dwFormOfType, pszUserType);
  992. }
  993. STDMETHOD(SetExtent)(DWORD dwDrawAspect, SIZEL *psizel)
  994. {
  995. T* pT = static_cast<T*>(this);
  996. ATLTRACE(_T("IOleObjectImpl::SetExtent\n"));
  997. return pT->IOleObject_SetExtent(dwDrawAspect, psizel);
  998. }
  999. STDMETHOD(GetExtent)(DWORD dwDrawAspect, SIZEL *psizel)
  1000. {
  1001. T* pT = static_cast<T*>(this);
  1002. ATLTRACE(_T("IOleObjectImpl::GetExtent\n"));
  1003. if (dwDrawAspect != DVASPECT_CONTENT)
  1004. return E_FAIL;
  1005. if (psizel == NULL)
  1006. return E_POINTER;
  1007. *psizel = pT->m_sizeExtent;
  1008. return S_OK;
  1009. }
  1010. STDMETHOD(Advise)(IAdviseSink *pAdvSink, DWORD *pdwConnection)
  1011. {
  1012. T* pT = static_cast<T*>(this);
  1013. ATLTRACE(_T("IOleObjectImpl::Advise\n"));
  1014. return pT->IOleObject_Advise(pAdvSink, pdwConnection);
  1015. }
  1016. STDMETHOD(Unadvise)(DWORD dwConnection)
  1017. {
  1018. T* pT = static_cast<T*>(this);
  1019. ATLTRACE(_T("IOleObjectImpl::Unadvise\n"));
  1020. HRESULT hRes = E_FAIL;
  1021. if (pT->m_spOleAdviseHolder != NULL)
  1022. hRes = pT->m_spOleAdviseHolder->Unadvise(dwConnection);
  1023. return hRes;
  1024. }
  1025. STDMETHOD(EnumAdvise)(IEnumSTATDATA **ppenumAdvise)
  1026. {
  1027. T* pT = static_cast<T*>(this);
  1028. ATLTRACE(_T("IOleObjectImpl::EnumAdvise\n"));
  1029. HRESULT hRes = E_FAIL;
  1030. if (pT->m_spOleAdviseHolder != NULL)
  1031. hRes = pT->m_spOleAdviseHolder->EnumAdvise(ppenumAdvise);
  1032. return hRes;
  1033. }
  1034. STDMETHOD(GetMiscStatus)(DWORD dwAspect, DWORD *pdwStatus)
  1035. {
  1036. ATLTRACE(_T("IOleObjectImpl::GetMiscStatus\n"));
  1037. return OleRegGetMiscStatus(T::GetObjectCLSID(), dwAspect, pdwStatus);
  1038. }
  1039. STDMETHOD(SetColorScheme)(LOGPALETTE* /* pLogpal */)
  1040. {
  1041. ATLTRACENOTIMPL(_T("IOleObjectImpl::SetColorScheme"));
  1042. }
  1043. };
  1044. //local struct used for implementation
  1045. #pragma pack(push, 1)
  1046. struct _ATL_DLGTEMPLATEEX
  1047. {
  1048. WORD dlgVer;
  1049. WORD signature;
  1050. DWORD helpID;
  1051. DWORD exStyle;
  1052. DWORD style;
  1053. WORD cDlgItems;
  1054. short x;
  1055. short y;
  1056. short cx;
  1057. short cy;
  1058. };
  1059. #pragma pack(pop)
  1060. //////////////////////////////////////////////////////////////////////////////
  1061. // IPropertyPageImpl
  1062. template <class T>
  1063. class ATL_NO_VTABLE IPropertyPageImpl
  1064. {
  1065. public:
  1066. // IUnknown
  1067. //
  1068. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  1069. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IOleControlImpl)
  1070. void SetDirty(BOOL bDirty)
  1071. {
  1072. T* pT = static_cast<T*>(this);
  1073. if (!pT->m_bDirty && bDirty)
  1074. pT->m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY | PROPPAGESTATUS_VALIDATE);
  1075. pT->m_bDirty = bDirty;
  1076. }
  1077. IPropertyPageImpl()
  1078. {
  1079. T* pT = static_cast<T*>(this);
  1080. pT->m_pPageSite = NULL;
  1081. pT->m_size.cx = 0;
  1082. pT->m_size.cy = 0;
  1083. pT->m_dwTitleID = 0;
  1084. pT->m_dwHelpFileID = 0;
  1085. pT->m_dwDocStringID = 0;
  1086. pT->m_dwHelpContext = 0;
  1087. pT->m_ppUnk = NULL;
  1088. pT->m_nObjects = 0;
  1089. pT->m_bDirty = FALSE;
  1090. pT->m_hWnd = NULL;
  1091. }
  1092. ~IPropertyPageImpl()
  1093. {
  1094. T* pT = static_cast<T*>(this);
  1095. if (pT->m_pPageSite != NULL)
  1096. pT->m_pPageSite->Release();
  1097. for (UINT i = 0; i < m_nObjects; i++)
  1098. pT->m_ppUnk[i]->Release();
  1099. delete[] pT->m_ppUnk;
  1100. }
  1101. // IPropertyPage
  1102. //
  1103. STDMETHOD(SetPageSite)(IPropertyPageSite *pPageSite)
  1104. {
  1105. T* pT = static_cast<T*>(this);
  1106. ATLTRACE(_T("IPropertyPageImpl::SetPageSite\n"));
  1107. if (!pPageSite && pT->m_pPageSite)
  1108. {
  1109. pT->m_pPageSite->Release();
  1110. return S_OK;
  1111. }
  1112. if (!pPageSite && !pT->m_pPageSite)
  1113. return S_OK;
  1114. if (pPageSite && pT->m_pPageSite)
  1115. {
  1116. ATLTRACE(_T("Error : setting page site again with non NULL value\n"));
  1117. return E_UNEXPECTED;
  1118. }
  1119. pT->m_pPageSite = pPageSite;
  1120. pT->m_pPageSite->AddRef();
  1121. return S_OK;
  1122. }
  1123. STDMETHOD(Activate)(HWND hWndParent, LPCRECT pRect, BOOL /* bModal */)
  1124. {
  1125. T* pT = static_cast<T*>(this);
  1126. ATLTRACE(_T("IPropertyPageImpl::Activate\n"));
  1127. if (pRect == NULL)
  1128. {
  1129. ATLTRACE(_T("Error : Passed a NULL rect\n"));
  1130. return E_POINTER;
  1131. }
  1132. pT->m_hWnd = pT->Create(hWndParent);
  1133. Move(pRect);
  1134. m_size.cx = pRect->right - pRect->left;
  1135. m_size.cy = pRect->bottom - pRect->top;
  1136. return S_OK;
  1137. }
  1138. STDMETHOD(Deactivate)( void)
  1139. {
  1140. T* pT = static_cast<T*>(this);
  1141. ATLTRACE(_T("IPropertyPageImpl::Deactivate\n"));
  1142. if (pT->m_hWnd)
  1143. {
  1144. ATLTRACE(_T("Destroying Dialog\n"));
  1145. if (::IsWindow(pT->m_hWnd))
  1146. pT->DestroyWindow();
  1147. pT->m_hWnd = NULL;
  1148. }
  1149. return S_OK;
  1150. }
  1151. STDMETHOD(GetPageInfo)(PROPPAGEINFO *pPageInfo)
  1152. {
  1153. T* pT = static_cast<T*>(this);
  1154. ATLTRACE(_T("IPropertyPageImpl::GetPageInfo\n"));
  1155. if (pPageInfo == NULL)
  1156. {
  1157. ATLTRACE(_T("Error : PROPPAGEINFO passed == NULL\n"));
  1158. return E_POINTER;
  1159. }
  1160. HRSRC hRsrc = FindResource(_Module.GetResourceInstance(),
  1161. MAKEINTRESOURCE(T::IDD), RT_DIALOG);
  1162. if (hRsrc == NULL)
  1163. {
  1164. ATLTRACE(_T("Could not find resource template\n"));
  1165. return E_UNEXPECTED;
  1166. }
  1167. HGLOBAL hGlob = LoadResource(_Module.GetResourceInstance(), hRsrc);
  1168. DLGTEMPLATE* pTemp = (DLGTEMPLATE*)LockResource(hGlob);
  1169. if (pTemp == NULL)
  1170. {
  1171. ATLTRACE(_T("Could not load resource template\n"));
  1172. return E_UNEXPECTED;
  1173. }
  1174. pT->GetDialogSize(pTemp, &m_size);
  1175. pPageInfo->cb = sizeof(PROPPAGEINFO);
  1176. pPageInfo->pszTitle = LoadStringHelper(pT->m_dwTitleID);
  1177. pPageInfo->size = m_size;
  1178. pPageInfo->pszHelpFile = LoadStringHelper(pT->m_dwHelpFileID);
  1179. pPageInfo->pszDocString = LoadStringHelper(pT->m_dwDocStringID);
  1180. pPageInfo->dwHelpContext = pT->m_dwHelpContext;
  1181. return S_OK;
  1182. }
  1183. STDMETHOD(SetObjects)(ULONG nObjects, IUnknown **ppUnk)
  1184. {
  1185. T* pT = static_cast<T*>(this);
  1186. ATLTRACE(_T("IPropertyPageImpl::SetObjects\n"));
  1187. if (ppUnk == NULL)
  1188. return E_POINTER;
  1189. if (pT->m_ppUnk != NULL && pT->m_nObjects > 0)
  1190. {
  1191. for (UINT iObj = 0; iObj < pT->m_nObjects; iObj++)
  1192. pT->m_ppUnk[iObj]->Release();
  1193. delete [] pT->m_ppUnk;
  1194. }
  1195. pT->m_ppUnk = NULL;
  1196. ATLTRY(pT->m_ppUnk = new IUnknown*[nObjects]);
  1197. if (pT->m_ppUnk == NULL)
  1198. return E_OUTOFMEMORY;
  1199. for (UINT i = 0; i < nObjects; i++)
  1200. {
  1201. ppUnk[i]->AddRef();
  1202. pT->m_ppUnk[i] = ppUnk[i];
  1203. }
  1204. pT->m_nObjects = nObjects;
  1205. return S_OK;
  1206. }
  1207. STDMETHOD(Show)(UINT nCmdShow)
  1208. {
  1209. T* pT = static_cast<T*>(this);
  1210. ATLTRACE(_T("IPropertyPageImpl::Show\n"));
  1211. if (pT->m_hWnd == NULL)
  1212. return E_UNEXPECTED;
  1213. ShowWindow(pT->m_hWnd, nCmdShow);
  1214. return S_OK;
  1215. }
  1216. STDMETHOD(Move)(LPCRECT pRect)
  1217. {
  1218. T* pT = static_cast<T*>(this);
  1219. ATLTRACE(_T("IPropertyPageImpl::Move\n"));
  1220. if (pT->m_hWnd == NULL)
  1221. return E_UNEXPECTED;
  1222. if (pRect == NULL)
  1223. return E_POINTER;
  1224. MoveWindow(pT->m_hWnd, pRect->left, pRect->top, pRect->right - pRect->left,
  1225. pRect->bottom - pRect->top, TRUE);
  1226. return S_OK;
  1227. }
  1228. STDMETHOD(IsPageDirty)(void)
  1229. {
  1230. T* pT = static_cast<T*>(this);
  1231. ATLTRACE(_T("IPropertyPageImpl::IsPageDirty\n"));
  1232. return pT->m_bDirty ? S_OK : S_FALSE;
  1233. }
  1234. STDMETHOD(Apply)(void)
  1235. {
  1236. T* pT = static_cast<T*>(this);
  1237. ATLTRACE(_T("IPropertyPageImpl::Apply\n"));
  1238. return S_OK;
  1239. }
  1240. STDMETHOD(Help)(LPCOLESTR pszHelpDir)
  1241. {
  1242. T* pT = static_cast<T*>(this);
  1243. USES_CONVERSION;
  1244. ATLTRACE(_T("IPropertyPageImpl::Help\n"));
  1245. WinHelp(pT->m_hWnd, OLE2CT(pszHelpDir), HELP_CONTEXTPOPUP, NULL);
  1246. return S_OK;
  1247. }
  1248. STDMETHOD(TranslateAccelerator)(MSG *pMsg)
  1249. {
  1250. T* pT = static_cast<T*>(this);
  1251. ATLTRACE(_T("IPropertyPageImpl::TranslateAccelerator\n"));
  1252. if ((pMsg->message < WM_KEYFIRST || pMsg->message > WM_KEYLAST) &&
  1253. (pMsg->message < WM_MOUSEFIRST || pMsg->message > WM_MOUSELAST))
  1254. return S_FALSE;
  1255. return (IsDialogMessage(pT->m_hWnd, pMsg)) ? S_OK : S_FALSE;
  1256. }
  1257. IPropertyPageSite* m_pPageSite;
  1258. IUnknown** m_ppUnk;
  1259. ULONG m_nObjects;
  1260. SIZE m_size;
  1261. UINT m_dwTitleID;
  1262. UINT m_dwHelpFileID;
  1263. UINT m_dwDocStringID;
  1264. DWORD m_dwHelpContext;
  1265. BOOL m_bDirty;
  1266. //methods
  1267. public:
  1268. BEGIN_MSG_MAP(IPropertyPageImpl<T>)
  1269. MESSAGE_HANDLER(WM_STYLECHANGING, OnStyleChange)
  1270. END_MSG_MAP()
  1271. LRESULT OnStyleChange(UINT, WPARAM wParam, LPARAM lParam, BOOL&)
  1272. {
  1273. if (wParam == GWL_EXSTYLE)
  1274. {
  1275. LPSTYLESTRUCT lpss = (LPSTYLESTRUCT) lParam;
  1276. lpss->styleNew |= WS_EX_CONTROLPARENT;
  1277. return 0;
  1278. }
  1279. return 1;
  1280. }
  1281. LPOLESTR LoadStringHelper(UINT idRes)
  1282. {
  1283. USES_CONVERSION;
  1284. TCHAR szTemp[_MAX_PATH];
  1285. LPOLESTR sz = (LPOLESTR)CoTaskMemAlloc(_MAX_PATH*sizeof(OLECHAR));
  1286. if (sz == NULL)
  1287. return NULL;
  1288. sz[0] = NULL;
  1289. if (LoadString(_Module.GetResourceInstance(), idRes, szTemp, _MAX_PATH))
  1290. ocscpy(sz, T2OLE(szTemp));
  1291. else
  1292. {
  1293. ATLTRACE(_T("Error : Failed to load string from res\n"));
  1294. }
  1295. return sz;
  1296. }
  1297. void GetDialogSize(const DLGTEMPLATE* pTemplate, SIZE* pSize)
  1298. {
  1299. // If the dialog has a font we use it otherwise we default
  1300. // to the system font.
  1301. if (HasFont(pTemplate))
  1302. {
  1303. TCHAR szFace[LF_FACESIZE];
  1304. WORD wFontSize = 0;
  1305. GetFont(pTemplate, szFace, &wFontSize);
  1306. GetSizeInDialogUnits(pTemplate, pSize);
  1307. ConvertDialogUnitsToPixels(szFace, wFontSize, pSize);
  1308. }
  1309. else
  1310. {
  1311. GetSizeInDialogUnits(pTemplate, pSize);
  1312. LONG nDlgBaseUnits = GetDialogBaseUnits();
  1313. pSize->cx = MulDiv(pSize->cx, LOWORD(nDlgBaseUnits), 4);
  1314. pSize->cy = MulDiv(pSize->cy, HIWORD(nDlgBaseUnits), 8);
  1315. }
  1316. }
  1317. static void ConvertDialogUnitsToPixels(LPCTSTR pszFontFace, WORD wFontSize, SIZE* pSizePixel)
  1318. {
  1319. // Attempt to create the font to be used in the dialog box
  1320. UINT cxSysChar, cySysChar;
  1321. LOGFONT lf;
  1322. HDC hDC = ::GetDC(NULL);
  1323. int cxDlg = pSizePixel->cx;
  1324. int cyDlg = pSizePixel->cy;
  1325. ZeroMemory(&lf, sizeof(LOGFONT));
  1326. lf.lfHeight = -MulDiv(wFontSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
  1327. lf.lfWeight = FW_NORMAL;
  1328. lf.lfCharSet = DEFAULT_CHARSET;
  1329. lstrcpy(lf.lfFaceName, pszFontFace);
  1330. HFONT hNewFont = CreateFontIndirect(&lf);
  1331. if (hNewFont != NULL)
  1332. {
  1333. TEXTMETRIC tm;
  1334. SIZE size;
  1335. HFONT hFontOld = (HFONT)SelectObject(hDC, hNewFont);
  1336. GetTextMetrics(hDC, &tm);
  1337. cySysChar = tm.tmHeight + tm.tmExternalLeading;
  1338. ::GetTextExtentPoint(hDC,
  1339. _T("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), 52,
  1340. &size);
  1341. cxSysChar = (size.cx + 26) / 52;
  1342. SelectObject(hDC, hFontOld);
  1343. DeleteObject(hNewFont);
  1344. }
  1345. else
  1346. {
  1347. // Could not create the font so just use the system's values
  1348. cxSysChar = LOWORD(GetDialogBaseUnits());
  1349. cySysChar = HIWORD(GetDialogBaseUnits());
  1350. }
  1351. ::ReleaseDC(NULL, hDC);
  1352. // Translate dialog units to pixels
  1353. pSizePixel->cx = MulDiv(cxDlg, cxSysChar, 4);
  1354. pSizePixel->cy = MulDiv(cyDlg, cySysChar, 8);
  1355. }
  1356. static BOOL IsDialogEx(const DLGTEMPLATE* pTemplate)
  1357. {
  1358. return ((_ATL_DLGTEMPLATEEX*)pTemplate)->signature == 0xFFFF;
  1359. }
  1360. static BOOL HasFont(const DLGTEMPLATE* pTemplate)
  1361. {
  1362. return (DS_SETFONT &
  1363. (IsDialogEx(pTemplate) ?
  1364. ((_ATL_DLGTEMPLATEEX*)pTemplate)->style : pTemplate->style));
  1365. }
  1366. static BYTE* GetFontSizeField(const DLGTEMPLATE* pTemplate)
  1367. {
  1368. BOOL bDialogEx = IsDialogEx(pTemplate);
  1369. WORD* pw;
  1370. if (bDialogEx)
  1371. pw = (WORD*)((_ATL_DLGTEMPLATEEX*)pTemplate + 1);
  1372. else
  1373. pw = (WORD*)(pTemplate + 1);
  1374. if (*pw == (WORD)-1) // Skip menu name string or ordinal
  1375. pw += 2; // WORDs
  1376. else
  1377. while(*pw++);
  1378. if (*pw == (WORD)-1) // Skip class name string or ordinal
  1379. pw += 2; // WORDs
  1380. else
  1381. while(*pw++);
  1382. while (*pw++); // Skip caption string
  1383. return (BYTE*)pw;
  1384. }
  1385. static BOOL GetFont(const DLGTEMPLATE* pTemplate, TCHAR* pszFace, WORD* pFontSize)
  1386. {
  1387. USES_CONVERSION;
  1388. if (!HasFont(pTemplate))
  1389. return FALSE;
  1390. BYTE* pb = GetFontSizeField(pTemplate);
  1391. *pFontSize = *(WORD*)pb;
  1392. // Skip over font attributes to get to the font name
  1393. pb += sizeof(WORD) * (IsDialogEx(pTemplate) ? 3 : 1);
  1394. _tcscpy(pszFace, W2T((WCHAR*)pb));
  1395. return TRUE;
  1396. }
  1397. static void GetSizeInDialogUnits(const DLGTEMPLATE* pTemplate, SIZE* pSize)
  1398. {
  1399. if (IsDialogEx(pTemplate))
  1400. {
  1401. pSize->cx = ((_ATL_DLGTEMPLATEEX*)pTemplate)->cx;
  1402. pSize->cy = ((_ATL_DLGTEMPLATEEX*)pTemplate)->cy;
  1403. }
  1404. else
  1405. {
  1406. pSize->cx = pTemplate->cx;
  1407. pSize->cy = pTemplate->cy;
  1408. }
  1409. }
  1410. };
  1411. //////////////////////////////////////////////////////////////////////////////
  1412. // IPropertyPage2Impl
  1413. template <class T>
  1414. class ATL_NO_VTABLE IPropertyPage2Impl : public IPropertyPageImpl<T>
  1415. {
  1416. public:
  1417. STDMETHOD(EditProperty)(DISPID dispID)
  1418. {
  1419. ATLTRACENOTIMPL(_T("IPropertyPage2Impl::EditProperty\n"));
  1420. }
  1421. };
  1422. //////////////////////////////////////////////////////////////////////////////
  1423. // IPerPropertyBrowsingImpl
  1424. template <class T>
  1425. class ATL_NO_VTABLE IPerPropertyBrowsingImpl
  1426. {
  1427. public:
  1428. // IUnknown
  1429. //
  1430. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  1431. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IPerPropertyBrowsingImpl)
  1432. STDMETHOD(GetDisplayString)(DISPID dispID,BSTR *pBstr)
  1433. {
  1434. ATLTRACE(_T("IPerPropertyBrowsingImpl::GetDisplayString\n"));
  1435. T* pT = static_cast<T*>(this);
  1436. CComVariant var;
  1437. if (FAILED(CComDispatchDriver::GetProperty(pT, dispID, &var)))
  1438. {
  1439. *pBstr = NULL;
  1440. return S_FALSE;
  1441. }
  1442. BSTR bstrTemp = var.bstrVal;
  1443. if (var.vt != VT_BSTR)
  1444. {
  1445. CComVariant varDest;
  1446. if (FAILED(::VariantChangeType(&varDest, &var, VARIANT_NOVALUEPROP, VT_BSTR)))
  1447. {
  1448. *pBstr = NULL;
  1449. return S_FALSE;
  1450. }
  1451. bstrTemp = varDest.bstrVal;
  1452. }
  1453. *pBstr = SysAllocString(bstrTemp);
  1454. return S_OK;
  1455. }
  1456. STDMETHOD(MapPropertyToPage)(DISPID dispID, CLSID *pClsid)
  1457. {
  1458. ATLTRACE(_T("IPerPropertyBrowsingImpl::MapPropertyToPage\n"));
  1459. T* pT = static_cast<T*>(this);
  1460. ATL_PROPMAP_ENTRY* pMap = T::GetPropertyMap();
  1461. _ASSERTE(pMap != NULL);
  1462. for(int i = 0; pMap[i].pclsidPropPage != NULL; i++)
  1463. {
  1464. if (pMap[i].szDesc == NULL)
  1465. continue;
  1466. if (pMap[i].dispid == dispID)
  1467. {
  1468. _ASSERTE(pMap[i].pclsidPropPage != NULL);
  1469. *pClsid = *(pMap[i].pclsidPropPage);
  1470. return S_OK;
  1471. }
  1472. }
  1473. *pClsid = CLSID_NULL;
  1474. return E_INVALIDARG;
  1475. }
  1476. STDMETHOD(GetPredefinedStrings)(DISPID dispID, CALPOLESTR *pCaStringsOut,CADWORD *pCaCookiesOut)
  1477. {
  1478. dispID;
  1479. ATLTRACE(_T("IPerPropertyBrowsingImpl::GetPredefinedStrings\n"));
  1480. if (pCaStringsOut == NULL || pCaCookiesOut == NULL)
  1481. return E_POINTER;
  1482. pCaStringsOut->cElems = 0;
  1483. pCaStringsOut->pElems = NULL;
  1484. pCaCookiesOut->cElems = 0;
  1485. pCaCookiesOut->pElems = NULL;
  1486. return S_OK;
  1487. }
  1488. STDMETHOD(GetPredefinedValue)(DISPID /*dispID*/, DWORD /*dwCookie*/, VARIANT* /*pVarOut*/)
  1489. {
  1490. ATLTRACENOTIMPL(_T("IPerPropertyBrowsingImpl::GetPredefinedValue"));
  1491. }
  1492. };
  1493. //////////////////////////////////////////////////////////////////////////////
  1494. // IViewObjectExImpl
  1495. template <class T>
  1496. class ATL_NO_VTABLE IViewObjectExImpl
  1497. {
  1498. public:
  1499. // IUnknown
  1500. //
  1501. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  1502. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IViewObjectExImpl)
  1503. // IViewObject
  1504. //
  1505. STDMETHOD(Draw)(DWORD dwDrawAspect, LONG lindex, void *pvAspect,
  1506. DVTARGETDEVICE *ptd, HDC hicTargetDev, HDC hdcDraw,
  1507. LPCRECTL prcBounds, LPCRECTL prcWBounds,
  1508. BOOL (__stdcall * /*pfnContinue*/)(DWORD_PTR dwContinue),
  1509. DWORD_PTR /*dwContinue*/)
  1510. {
  1511. T* pT = static_cast<T*>(this);
  1512. ATLTRACE(_T("IViewObjectExImpl::Draw\n"));
  1513. return pT->IViewObject_Draw(dwDrawAspect, lindex, pvAspect, ptd, hicTargetDev, hdcDraw,
  1514. prcBounds, prcWBounds);
  1515. }
  1516. STDMETHOD(GetColorSet)(DWORD /* dwDrawAspect */,LONG /* lindex */, void* /* pvAspect */, DVTARGETDEVICE* /* ptd */, HDC /* hicTargetDev */, LOGPALETTE** /* ppColorSet */)
  1517. {
  1518. ATLTRACENOTIMPL(_T("IViewObjectExImpl::GetColorSet"));
  1519. }
  1520. STDMETHOD(Freeze)(DWORD /* dwDrawAspect */, LONG /* lindex */, void* /* pvAspect */,DWORD* /* pdwFreeze */)
  1521. {
  1522. ATLTRACENOTIMPL(_T("IViewObjectExImpl::Freeze"));
  1523. }
  1524. STDMETHOD(Unfreeze)(DWORD /* dwFreeze */)
  1525. {
  1526. ATLTRACENOTIMPL(_T("IViewObjectExImpl::Unfreeze"));
  1527. }
  1528. STDMETHOD(SetAdvise)(DWORD /* aspects */, DWORD /* advf */, IAdviseSink* pAdvSink)
  1529. {
  1530. T* pT = static_cast<T*>(this);
  1531. ATLTRACE(_T("IViewObjectExImpl::SetAdvise\n"));
  1532. pT->m_spAdviseSink = pAdvSink;
  1533. return S_OK;
  1534. }
  1535. STDMETHOD(GetAdvise)(DWORD* /* pAspects */, DWORD* /* pAdvf */, IAdviseSink** ppAdvSink)
  1536. {
  1537. T* pT = static_cast<T*>(this);
  1538. ATLTRACE(_T("IViewObjectExImpl::GetAdvise\n"));
  1539. if (ppAdvSink != NULL)
  1540. {
  1541. *ppAdvSink = pT->m_spAdviseSink;
  1542. if (pT->m_spAdviseSink)
  1543. pT->m_spAdviseSink->AddRef();
  1544. }
  1545. return S_OK;
  1546. }
  1547. // IViewObject2
  1548. //
  1549. STDMETHOD(GetExtent)(DWORD /* dwDrawAspect */, LONG /* lindex */, DVTARGETDEVICE* /* ptd */, LPSIZEL lpsizel)
  1550. {
  1551. T* pT = static_cast<T*>(this);
  1552. ATLTRACE(_T("IViewObjectExImpl::GetExtent\n"));
  1553. *lpsizel = pT->m_sizeExtent;
  1554. return S_OK;
  1555. }
  1556. // IViewObjectEx
  1557. //
  1558. STDMETHOD(GetRect)(DWORD /* dwAspect */, LPRECTL /* pRect */)
  1559. {
  1560. ATLTRACENOTIMPL(_T("IViewObjectExImpl::GetRect"));
  1561. }
  1562. STDMETHOD(GetViewStatus)(DWORD* pdwStatus)
  1563. {
  1564. ATLTRACE(_T("IViewObjectExImpl::GetViewStatus\n"));
  1565. *pdwStatus =
  1566. // VIEWSTATUS_DVASPECTOPAQUE | VIEWSTATUS_DVASPECTTRANSPARENT |
  1567. // VIEWSTATUS_SOLIDBKGND |
  1568. VIEWSTATUS_OPAQUE;
  1569. return S_OK;
  1570. }
  1571. STDMETHOD(QueryHitPoint)(DWORD dwAspect, LPCRECT pRectBounds, POINT ptlLoc, LONG /* lCloseHint */, DWORD *pHitResult)
  1572. {
  1573. ATLTRACE(_T("IViewObjectExImpl::QueryHitPoint\n"));
  1574. if (dwAspect == DVASPECT_CONTENT)
  1575. {
  1576. *pHitResult = PtInRect(pRectBounds, ptlLoc) ? HITRESULT_HIT : HITRESULT_OUTSIDE;
  1577. return S_OK;
  1578. }
  1579. ATLTRACE(_T("Wrong DVASPECT\n"));
  1580. return E_FAIL;
  1581. }
  1582. STDMETHOD(QueryHitRect)(DWORD dwAspect, LPCRECT pRectBounds, LPCRECT prcLoc, LONG /* lCloseHint */, DWORD* pHitResult)
  1583. {
  1584. ATLTRACE(_T("IViewObjectExImpl::QueryHitRect\n"));
  1585. if (dwAspect == DVASPECT_CONTENT)
  1586. {
  1587. RECT rc;
  1588. *pHitResult = UnionRect(&rc, pRectBounds, prcLoc) ? HITRESULT_HIT : HITRESULT_OUTSIDE;
  1589. return S_OK;
  1590. }
  1591. ATLTRACE(_T("Wrong DVASPECT\n"));
  1592. return E_FAIL;
  1593. }
  1594. STDMETHOD(GetNaturalExtent)(DWORD dwAspect, LONG /* lindex */, DVTARGETDEVICE* /* ptd */, HDC /* hicTargetDev */, DVEXTENTINFO* pExtentInfo , LPSIZEL psizel)
  1595. {
  1596. T* pT = static_cast<T*>(this);
  1597. ATLTRACE(_T("IViewObjectExImpl::GetNaturalExtent\n"));
  1598. HRESULT hRes = E_FAIL;
  1599. if (dwAspect == DVASPECT_CONTENT)
  1600. {
  1601. if (pExtentInfo->dwExtentMode == DVEXTENT_CONTENT)
  1602. {
  1603. *psizel = pT->m_sizeNatural;
  1604. hRes = S_OK;
  1605. }
  1606. }
  1607. return hRes;
  1608. }
  1609. public:
  1610. };
  1611. //////////////////////////////////////////////////////////////////////////////
  1612. // IOleInPlaceObjectWindowlessImpl
  1613. //
  1614. template <class T>
  1615. class ATL_NO_VTABLE IOleInPlaceObjectWindowlessImpl
  1616. {
  1617. public:
  1618. // IUnknown
  1619. //
  1620. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  1621. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IOleInPlaceObjectWindowlessImpl)
  1622. // IOleWindow
  1623. //
  1624. // Change IOleInPlaceActiveObject::GetWindow as well
  1625. STDMETHOD(GetWindow)(HWND* phwnd)
  1626. {
  1627. ATLTRACE(_T("IOleInPlaceObjectWindowlessImpl::GetWindow\n"));
  1628. T* pT = static_cast<T*>(this);
  1629. HRESULT hRes = E_POINTER;
  1630. if (pT->m_bWasOnceWindowless)
  1631. return E_FAIL;
  1632. if (phwnd != NULL)
  1633. {
  1634. *phwnd = pT->m_hWnd;
  1635. hRes = (*phwnd == NULL) ? E_UNEXPECTED : S_OK;
  1636. }
  1637. return hRes;
  1638. }
  1639. STDMETHOD(ContextSensitiveHelp)(BOOL /* fEnterMode */)
  1640. {
  1641. ATLTRACENOTIMPL(_T("IOleInPlaceObjectWindowlessImpl::ContextSensitiveHelp"));
  1642. }
  1643. // IOleInPlaceObject
  1644. //
  1645. STDMETHOD(InPlaceDeactivate)(void)
  1646. {
  1647. T* pT = static_cast<T*>(this);
  1648. ATLTRACE(_T("IOleInPlaceObjectWindowlessImpl::InPlaceDeactivate\n"));
  1649. return pT->IOleInPlaceObject_InPlaceDeactivate();
  1650. }
  1651. STDMETHOD(UIDeactivate)(void)
  1652. {
  1653. T* pT = static_cast<T*>(this);
  1654. ATLTRACE(_T("IOleInPlaceObjectWindowlessImpl::UIDeactivate\n"));
  1655. return pT->IOleInPlaceObject_UIDeactivate();
  1656. }
  1657. STDMETHOD(SetObjectRects)(LPCRECT prcPos,LPCRECT prcClip)
  1658. {
  1659. T* pT = static_cast<T*>(this);
  1660. ATLTRACE(_T("IOleInPlaceObjectWindowlessImpl::SetObjectRects\n"));
  1661. return pT->IOleInPlaceObject_SetObjectRects(prcPos, prcClip);
  1662. }
  1663. STDMETHOD(ReactivateAndUndo)(void)
  1664. {
  1665. ATLTRACENOTIMPL(_T("IOleInPlaceObjectWindowlessImpl::ReactivateAndUndo"));
  1666. }
  1667. // IOleInPlaceObjectWindowless
  1668. //
  1669. STDMETHOD(OnWindowMessage)(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *plResult)
  1670. {
  1671. ATLTRACE(_T("IOleInPlaceObjectWindowlessImpl::OnWindowMessage\n"));
  1672. T* pT = static_cast<T*>(this);
  1673. return (pT->ProcessWindowMessage(pT->m_hWnd, msg, wParam, lParam, *plResult)) ? S_OK : S_FALSE;
  1674. }
  1675. STDMETHOD(GetDropTarget)(IDropTarget** /* ppDropTarget */)
  1676. {
  1677. ATLTRACENOTIMPL(_T("IOleInPlaceObjectWindowlessImpl::GetDropTarget"));
  1678. }
  1679. };
  1680. //////////////////////////////////////////////////////////////////////////////
  1681. // IOleInPlaceActiveObjectImpl
  1682. //
  1683. template <class T>
  1684. class ATL_NO_VTABLE IOleInPlaceActiveObjectImpl
  1685. {
  1686. public:
  1687. // IUnknown
  1688. //
  1689. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  1690. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IOleInPlaceActiveObjectImpl)
  1691. // IOleWindow
  1692. //
  1693. // Change IOleInPlaceObjectWindowless::GetWindow as well
  1694. STDMETHOD(GetWindow)(HWND *phwnd)
  1695. {
  1696. ATLTRACE(_T("IOleInPlaceActiveObjectImpl::GetWindow\n"));
  1697. T* pT = static_cast<T*>(this);
  1698. HRESULT hRes = E_POINTER;
  1699. if (pT->m_bWasOnceWindowless)
  1700. return E_FAIL;
  1701. if (phwnd != NULL)
  1702. {
  1703. *phwnd = pT->m_hWnd;
  1704. hRes = (*phwnd == NULL) ? E_UNEXPECTED : S_OK;
  1705. }
  1706. return hRes;
  1707. }
  1708. STDMETHOD(ContextSensitiveHelp)(BOOL /* fEnterMode */)
  1709. {
  1710. ATLTRACENOTIMPL(_T("IOleInPlaceActiveObjectImpl::ContextSensitiveHelp"));
  1711. }
  1712. // IOleInPlaceActiveObject
  1713. //
  1714. STDMETHOD(TranslateAccelerator)(LPMSG /* lpmsg */)
  1715. {
  1716. ATLTRACE(_T("IOleInPlaceActiveObjectImpl::TranslateAccelerator\n"));
  1717. return E_NOTIMPL;
  1718. }
  1719. STDMETHOD(OnFrameWindowActivate)(BOOL /* fActivate */)
  1720. {
  1721. ATLTRACE(_T("IOleInPlaceActiveObjectImpl::OnFrameWindowActivate\n"));
  1722. return S_OK;
  1723. }
  1724. STDMETHOD(OnDocWindowActivate)(BOOL /* fActivate */)
  1725. {
  1726. ATLTRACE(_T("IOleInPlaceActiveObjectImpl::OnDocWindowActivate\n"));
  1727. return S_OK;
  1728. }
  1729. STDMETHOD(ResizeBorder)(LPCRECT /* prcBorder */, IOleInPlaceUIWindow* /* pUIWindow */, BOOL /* fFrameWindow */)
  1730. {
  1731. ATLTRACE(_T("IOleInPlaceActiveObjectImpl::ResizeBorder\n"));
  1732. return S_OK;
  1733. }
  1734. STDMETHOD(EnableModeless)(BOOL /* fEnable */)
  1735. {
  1736. ATLTRACE(_T("IOleInPlaceActiveObjectImpl::EnableModeless\n"));
  1737. return S_OK;
  1738. }
  1739. };
  1740. //////////////////////////////////////////////////////////////////////////////
  1741. // ISpecifyPropertyPagesImpl
  1742. template <class T>
  1743. class ATL_NO_VTABLE ISpecifyPropertyPagesImpl
  1744. {
  1745. public:
  1746. // IUnknown
  1747. //
  1748. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  1749. _ATL_DEBUG_ADDREF_RELEASE_IMPL(ISpecifyPropertyPagesImpl)
  1750. // ISpecifyPropertyPages
  1751. //
  1752. STDMETHOD(GetPages)(CAUUID* pPages)
  1753. {
  1754. ATLTRACE(_T("ISpecifyPropertyPagesImpl::GetPages\n"));
  1755. T* pT = static_cast<T*>(this);
  1756. ATL_PROPMAP_ENTRY* pMap = T::GetPropertyMap();
  1757. return pT->ISpecifyPropertyPages_GetPages(pPages, pMap);
  1758. }
  1759. };
  1760. //////////////////////////////////////////////////////////////////////////////
  1761. // IPointerInactiveImpl
  1762. template <class T>
  1763. class ATL_NO_VTABLE IPointerInactiveImpl
  1764. {
  1765. public:
  1766. // IUnknown
  1767. //
  1768. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  1769. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IPointerInactiveImpl)
  1770. // IPointerInactive
  1771. //
  1772. STDMETHOD(GetActivationPolicy)(DWORD *pdwPolicy)
  1773. {
  1774. ATLTRACENOTIMPL(_T("IPointerInactiveImpl::GetActivationPolicy"));
  1775. }
  1776. STDMETHOD(OnInactiveMouseMove)(LPCRECT pRectBounds, long x, long y, DWORD dwMouseMsg)
  1777. {
  1778. ATLTRACENOTIMPL(_T("IPointerInactiveImpl::OnInactiveMouseMove"));
  1779. }
  1780. STDMETHOD(OnInactiveSetCursor)(LPCRECT pRectBounds, long x, long y, DWORD dwMouseMsg, BOOL fSetAlways)
  1781. {
  1782. ATLTRACENOTIMPL(_T("IPointerInactiveImpl::OnInactiveSetCursor"));
  1783. }
  1784. };
  1785. //////////////////////////////////////////////////////////////////////////////
  1786. // IRunnableObjectImpl
  1787. template <class T>
  1788. class ATL_NO_VTABLE IRunnableObjectImpl
  1789. {
  1790. public:
  1791. // IUnknown
  1792. //
  1793. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  1794. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IRunnableObjectImpl)
  1795. // IRunnableObject
  1796. //
  1797. STDMETHOD(GetRunningClass)(LPCLSID lpClsid)
  1798. {
  1799. ATLTRACE(_T("IRunnableObjectImpl::GetRunningClass\n"));
  1800. T* pT = static_cast<T*>(this);
  1801. *lpClsid = GUID_NULL;
  1802. return E_UNEXPECTED;
  1803. }
  1804. STDMETHOD(Run)(LPBINDCTX)
  1805. {
  1806. ATLTRACE(_T("IRunnableObjectImpl::Run\n"));
  1807. return S_OK;
  1808. }
  1809. virtual BOOL STDMETHODCALLTYPE IsRunning()
  1810. {
  1811. ATLTRACE(_T("IRunnableObjectImpl::IsRunning\n"));
  1812. return TRUE;
  1813. }
  1814. STDMETHOD(LockRunning)(BOOL /*fLock*/, BOOL /*fLastUnlockCloses*/)
  1815. {
  1816. ATLTRACE(_T("IRunnableObjectImpl::LockRunning\n"));
  1817. return S_OK;
  1818. }
  1819. STDMETHOD(SetContainedObject)(BOOL /*fContained*/)
  1820. {
  1821. ATLTRACE(_T("IRunnableObjectImpl::SetContainedObject\n"));
  1822. return S_OK;
  1823. }
  1824. };
  1825. //////////////////////////////////////////////////////////////////////////////
  1826. // IDataObjectImpl
  1827. template <class T>
  1828. class ATL_NO_VTABLE IDataObjectImpl
  1829. {
  1830. public:
  1831. // IUnknown
  1832. //
  1833. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  1834. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IDataObjectImpl)
  1835. // IDataObject
  1836. //
  1837. STDMETHOD(GetData)(FORMATETC *pformatetcIn, STGMEDIUM *pmedium)
  1838. {
  1839. ATLTRACE(_T("IDataObjectImpl::GetData\n"));
  1840. T* pT = (T*) this;
  1841. return pT->IDataObject_GetData(pformatetcIn, pmedium);
  1842. }
  1843. STDMETHOD(GetDataHere)(FORMATETC* /* pformatetc */, STGMEDIUM* /* pmedium */)
  1844. {
  1845. ATLTRACENOTIMPL(_T("IDataObjectImpl::GetDataHere"));
  1846. }
  1847. STDMETHOD(QueryGetData)(FORMATETC* /* pformatetc */)
  1848. {
  1849. ATLTRACENOTIMPL(_T("IDataObjectImpl::QueryGetData"));
  1850. }
  1851. STDMETHOD(GetCanonicalFormatEtc)(FORMATETC* /* pformatectIn */,FORMATETC* /* pformatetcOut */)
  1852. {
  1853. ATLTRACENOTIMPL(_T("IDataObjectImpl::GetCanonicalFormatEtc"));
  1854. }
  1855. STDMETHOD(SetData)(FORMATETC* /* pformatetc */, STGMEDIUM* /* pmedium */, BOOL /* fRelease */)
  1856. {
  1857. ATLTRACENOTIMPL(_T("IDataObjectImpl::SetData"));
  1858. }
  1859. STDMETHOD(EnumFormatEtc)(DWORD /* dwDirection */, IEnumFORMATETC** /* ppenumFormatEtc */)
  1860. {
  1861. ATLTRACENOTIMPL(_T("IDataObjectImpl::EnumFormatEtc"));
  1862. }
  1863. STDMETHOD(DAdvise)(FORMATETC *pformatetc, DWORD advf, IAdviseSink *pAdvSink,
  1864. DWORD *pdwConnection)
  1865. {
  1866. ATLTRACE(_T("IDataObjectImpl::DAdvise\n"));
  1867. T* pT = static_cast<T*>(this);
  1868. HRESULT hr = S_OK;
  1869. if (pT->m_spDataAdviseHolder == NULL)
  1870. hr = CreateDataAdviseHolder(&pT->m_spDataAdviseHolder);
  1871. if (hr == S_OK)
  1872. hr = pT->m_spDataAdviseHolder->Advise((IDataObject*)this, pformatetc, advf, pAdvSink, pdwConnection);
  1873. return hr;
  1874. }
  1875. STDMETHOD(DUnadvise)(DWORD dwConnection)
  1876. {
  1877. ATLTRACE(_T("IDataObjectImpl::DUnadvise\n"));
  1878. T* pT = static_cast<T*>(this);
  1879. HRESULT hr = S_OK;
  1880. if (pT->m_spDataAdviseHolder == NULL)
  1881. hr = OLE_E_NOCONNECTION;
  1882. else
  1883. hr = pT->m_spDataAdviseHolder->Unadvise(dwConnection);
  1884. return hr;
  1885. }
  1886. STDMETHOD(EnumDAdvise)(IEnumSTATDATA **ppenumAdvise)
  1887. {
  1888. ATLTRACE(_T("IDataObjectImpl::EnumDAdvise\n"));
  1889. T* pT = static_cast<T*>(this);
  1890. HRESULT hr = E_FAIL;
  1891. if (pT->m_spDataAdviseHolder != NULL)
  1892. hr = pT->m_spDataAdviseHolder->EnumAdvise(ppenumAdvise);
  1893. return hr;
  1894. }
  1895. };
  1896. //////////////////////////////////////////////////////////////////////////////
  1897. // IPropertyNotifySinkCP
  1898. template <class T, class CDV = CComDynamicUnkArray >
  1899. class ATL_NO_VTABLE IPropertyNotifySinkCP :
  1900. public IConnectionPointImpl<T, &IID_IPropertyNotifySink, CDV>
  1901. {
  1902. public:
  1903. typedef CFirePropNotifyEvent _ATL_PROP_NOTIFY_EVENT_CLASS;
  1904. };
  1905. //////////////////////////////////////////////////////////////////////////////
  1906. // IObjectSafety
  1907. //
  1908. template <class T>
  1909. class ATL_NO_VTABLE IObjectSafetyImpl
  1910. {
  1911. public:
  1912. IObjectSafetyImpl()
  1913. {
  1914. m_dwSafety = 0;
  1915. }
  1916. // IUnknown
  1917. //
  1918. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  1919. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IObjectSafetyImpl)
  1920. // IObjectSafety
  1921. //
  1922. STDMETHOD(GetInterfaceSafetyOptions)(REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions)
  1923. {
  1924. ATLTRACE(_T("IObjectSafetyImpl::GetInterfaceSafetyOptions\n"));
  1925. if (pdwSupportedOptions == NULL || pdwEnabledOptions == NULL)
  1926. return E_POINTER;
  1927. HRESULT hr = S_OK;
  1928. if (riid == IID_IDispatch)
  1929. {
  1930. *pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER;
  1931. *pdwEnabledOptions = m_dwSafety & INTERFACESAFE_FOR_UNTRUSTED_CALLER;
  1932. }
  1933. else
  1934. {
  1935. *pdwSupportedOptions = 0;
  1936. *pdwEnabledOptions = 0;
  1937. hr = E_NOINTERFACE;
  1938. }
  1939. return hr;
  1940. }
  1941. STDMETHOD(SetInterfaceSafetyOptions)(REFIID riid, DWORD dwOptionSetMask, DWORD dwEnabledOptions)
  1942. {
  1943. ATLTRACE(_T("IObjectSafetyImpl::SetInterfaceSafetyOptions\n"));
  1944. // If we're being asked to set our safe for scripting option then oblige
  1945. if (riid == IID_IDispatch)
  1946. {
  1947. // Store our current safety level to return in GetInterfaceSafetyOptions
  1948. m_dwSafety = dwEnabledOptions & dwOptionSetMask;
  1949. return S_OK;
  1950. }
  1951. return E_NOINTERFACE;
  1952. }
  1953. DWORD m_dwSafety;
  1954. };
  1955. template <class T>
  1956. class ATL_NO_VTABLE IOleLinkImpl
  1957. {
  1958. // IUnknown
  1959. //
  1960. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  1961. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IOleLinkImpl)
  1962. STDMETHOD(SetUpdateOptions)(DWORD /* dwUpdateOpt */)
  1963. {
  1964. ATLTRACENOTIMPL(_T("IOleLinkImpl::SetUpdateOptions"));
  1965. }
  1966. STDMETHOD(GetUpdateOptions)(DWORD* /* pdwUpdateOpt */)
  1967. {
  1968. ATLTRACENOTIMPL(_T("IOleLinkImpl::GetUpdateOptions"));
  1969. }
  1970. STDMETHOD(SetSourceMoniker)(IMoniker* /* pmk */, REFCLSID /* rclsid */)
  1971. {
  1972. ATLTRACENOTIMPL(_T("IOleLinkImpl::SetSourceMoniker"));
  1973. }
  1974. STDMETHOD(GetSourceMoniker)(IMoniker** /* ppmk */)
  1975. {
  1976. ATLTRACENOTIMPL(_T("IOleLinkImpl::GetSourceMoniker"));
  1977. };
  1978. STDMETHOD(SetSourceDisplayName)(LPCOLESTR /* pszStatusText */)
  1979. {
  1980. ATLTRACENOTIMPL(_T("IOleLinkImpl::SetSourceDisplayName"));
  1981. }
  1982. STDMETHOD(GetSourceDisplayName)(LPOLESTR *ppszDisplayName)
  1983. {
  1984. ATLTRACE(_T("IOleLink::GetSourceDisplayName\n"));
  1985. *ppszDisplayName = NULL;
  1986. return E_FAIL;
  1987. }
  1988. STDMETHOD(BindToSource)(DWORD /* bindflags */, IBindCtx* /* pbc */)
  1989. {
  1990. ATLTRACENOTIMPL(_T("IOleLinkImpl::BindToSource\n"));
  1991. };
  1992. STDMETHOD(BindIfRunning)()
  1993. {
  1994. ATLTRACE(_T("IOleLinkImpl::BindIfRunning\n"));
  1995. return S_OK;
  1996. };
  1997. STDMETHOD(GetBoundSource)(IUnknown** /* ppunk */)
  1998. {
  1999. ATLTRACENOTIMPL(_T("IOleLinkImpl::GetBoundSource"));
  2000. };
  2001. STDMETHOD(UnbindSource)()
  2002. {
  2003. ATLTRACENOTIMPL(_T("IOleLinkImpl::UnbindSource"));
  2004. };
  2005. STDMETHOD(Update)(IBindCtx* /* pbc */)
  2006. {
  2007. ATLTRACENOTIMPL(_T("IOleLinkImpl::Update"));
  2008. };
  2009. };
  2010. template <class T>
  2011. class ATL_NO_VTABLE IBindStatusCallbackImpl
  2012. {
  2013. public:
  2014. // IUnknown
  2015. //
  2016. STDMETHOD(QueryInterface)(REFIID riid, void ** ppvObject) = 0;
  2017. _ATL_DEBUG_ADDREF_RELEASE_IMPL(IBindStatusCallbackImpl)
  2018. // IBindStatusCallback
  2019. //
  2020. STDMETHOD(OnStartBinding)(DWORD /* dwReserved */, IBinding *pBinding)
  2021. {
  2022. ATLTRACE(_T("IBindStatusCallbackImpl::OnStartBinding\n"));
  2023. return S_OK;
  2024. }
  2025. STDMETHOD(GetPriority)(LONG* /* pnPriority */)
  2026. {
  2027. ATLTRACENOTIMPL(_T("IBindStatusCallbackImpl::GetPriority"));
  2028. }
  2029. STDMETHOD(OnLowResource)(DWORD /* reserved */)
  2030. {
  2031. ATLTRACE(_T("IBindStatusCallbackImpl::OnLowResource\n"));
  2032. return S_OK;
  2033. }
  2034. STDMETHOD(OnProgress)(ULONG /* ulProgress */, ULONG /* ulProgressMax */, ULONG /* ulStatusCode */, LPCWSTR /* szStatusText */)
  2035. {
  2036. ATLTRACE(_T("IBindStatusCallbackImpl::OnProgress\n"));
  2037. return S_OK;
  2038. }
  2039. STDMETHOD(OnStopBinding)(HRESULT /* hresult */, LPCWSTR /* szError */)
  2040. {
  2041. ATLTRACE(_T("IBindStatusCallbackImpl::OnStopBinding\n"));
  2042. return S_OK;
  2043. }
  2044. STDMETHOD(GetBindInfo)(DWORD* /* pgrfBINDF */, BINDINFO* /* pBindInfo */)
  2045. {
  2046. ATLTRACE(_T("IBindStatusCallbackImpl::GetBindInfo\n"));
  2047. return S_OK;
  2048. }
  2049. STDMETHOD(OnDataAvailable)(DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
  2050. {
  2051. ATLTRACE(_T("IBindStatusCallbackImpl::OnDataAvailable\n"));
  2052. return S_OK;
  2053. }
  2054. STDMETHOD(OnObjectAvailable)(REFIID /* riid */, IUnknown* /* punk */)
  2055. {
  2056. ATLTRACE(_T("IBindStatusCallbackImpl::OnObjectAvailable\n"));
  2057. return S_OK;
  2058. }
  2059. };
  2060. template <class T>
  2061. class ATL_NO_VTABLE CBindStatusCallback :
  2062. public CComObjectRootEx<T::_ThreadModel::ThreadModelNoCS>,
  2063. public IBindStatusCallbackImpl<T>
  2064. {
  2065. typedef void (T::*ATL_PDATAAVAILABLE)(CBindStatusCallback<T>* pbsc, BYTE* pBytes, DWORD dwSize);
  2066. public:
  2067. BEGIN_COM_MAP(CBindStatusCallback<T>)
  2068. COM_INTERFACE_ENTRY_IID(IID_IBindStatusCallback, IBindStatusCallbackImpl<T>)
  2069. END_COM_MAP()
  2070. CBindStatusCallback()
  2071. {
  2072. m_pT = NULL;
  2073. m_pFunc = NULL;
  2074. }
  2075. ~CBindStatusCallback()
  2076. {
  2077. ATLTRACE(_T("~CBindStatusCallback\n"));
  2078. }
  2079. STDMETHOD(OnStartBinding)(DWORD dwReserved, IBinding *pBinding)
  2080. {
  2081. ATLTRACE(_T("CBindStatusCallback::OnStartBinding\n"));
  2082. m_spBinding = pBinding;
  2083. return S_OK;
  2084. }
  2085. STDMETHOD(GetPriority)(LONG *pnPriority)
  2086. {
  2087. ATLTRACENOTIMPL(_T("CBindStatusCallback::GetPriority"));
  2088. }
  2089. STDMETHOD(OnLowResource)(DWORD reserved)
  2090. {
  2091. ATLTRACENOTIMPL(_T("CBindStatusCallback::OnLowResource"));
  2092. }
  2093. STDMETHOD(OnProgress)(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
  2094. {
  2095. ATLTRACENOTIMPL(_T("CBindStatusCallback::OnProgress"));
  2096. }
  2097. STDMETHOD(OnStopBinding)(HRESULT hresult, LPCWSTR szError)
  2098. {
  2099. ATLTRACE(_T("CBindStatusCallback::OnStopBinding\n"));
  2100. m_spBinding.Release();
  2101. m_spBindCtx.Release();
  2102. m_spMoniker.Release();
  2103. return S_OK;
  2104. }
  2105. STDMETHOD(GetBindInfo)(DWORD *pgrfBINDF, BINDINFO *pbindInfo)
  2106. {
  2107. ATLTRACE(_T("CBindStatusCallback::GetBindInfo\n"));
  2108. if (pbindInfo==NULL || pbindInfo->cbSize==0 || pgrfBINDF==NULL)
  2109. return E_INVALIDARG;
  2110. *pgrfBINDF = BINDF_ASYNCHRONOUS | BINDF_ASYNCSTORAGE |
  2111. BINDF_GETNEWESTVERSION | BINDF_NOWRITECACHE;
  2112. ULONG cbSize = pbindInfo->cbSize; // remember incoming cbSize
  2113. memset(pbindInfo, 0, cbSize); // zero out structure
  2114. pbindInfo->cbSize = cbSize; // restore cbSize
  2115. pbindInfo->dwBindVerb = BINDVERB_GET; // set verb
  2116. return S_OK;
  2117. }
  2118. STDMETHOD(OnDataAvailable)(DWORD grfBSCF, DWORD dwSize, FORMATETC *pformatetc, STGMEDIUM *pstgmed)
  2119. {
  2120. ATLTRACE(_T("CBindStatusCallback::OnDataAvailable\n"));
  2121. HRESULT hr = S_OK;
  2122. // Get the Stream passed
  2123. if (BSCF_FIRSTDATANOTIFICATION & grfBSCF)
  2124. {
  2125. if (!m_spStream && pstgmed->tymed == TYMED_ISTREAM)
  2126. m_spStream = pstgmed->pstm;
  2127. }
  2128. DWORD dwRead = dwSize - m_dwTotalRead; // Minimum amount available that hasn't been read
  2129. DWORD dwActuallyRead = 0; // Placeholder for amount read during this pull
  2130. // If there is some data to be read then go ahead and read them
  2131. if (m_spStream)
  2132. {
  2133. if (dwRead > 0)
  2134. {
  2135. BYTE* pBytes = NULL;
  2136. ATLTRY(pBytes = new BYTE[dwRead + 1]);
  2137. if (pBytes == NULL)
  2138. return S_FALSE;
  2139. hr = m_spStream->Read(pBytes, dwRead, &dwActuallyRead);
  2140. if (SUCCEEDED(hr))
  2141. {
  2142. pBytes[dwActuallyRead] = 0;
  2143. if (dwActuallyRead>0)
  2144. {
  2145. (m_pT->*m_pFunc)(this, pBytes, dwActuallyRead);
  2146. m_dwTotalRead += dwActuallyRead;
  2147. }
  2148. }
  2149. delete[] pBytes;
  2150. }
  2151. }
  2152. if (BSCF_LASTDATANOTIFICATION & grfBSCF)
  2153. m_spStream.Release();
  2154. return hr;
  2155. }
  2156. STDMETHOD(OnObjectAvailable)(REFIID riid, IUnknown *punk)
  2157. {
  2158. ATLTRACENOTIMPL(_T("CBindStatusCallback::OnObjectAvailable"));
  2159. }
  2160. HRESULT _StartAsyncDownload(BSTR bstrURL, IUnknown* pUnkContainer, BOOL bRelative)
  2161. {
  2162. m_dwTotalRead = 0;
  2163. m_dwAvailableToRead = 0;
  2164. HRESULT hr = S_OK;
  2165. CComQIPtr<IServiceProvider, &IID_IServiceProvider> spServiceProvider(pUnkContainer);
  2166. CComPtr<IBindHost> spBindHost;
  2167. CComPtr<IStream> spStream;
  2168. if (spServiceProvider)
  2169. spServiceProvider->QueryService(SID_IBindHost, IID_IBindHost, (void**)&spBindHost);
  2170. if (spBindHost == NULL)
  2171. {
  2172. if (bRelative)
  2173. return E_NOINTERFACE; // relative asked for, but no IBindHost
  2174. hr = CreateURLMoniker(NULL, bstrURL, &m_spMoniker);
  2175. if (SUCCEEDED(hr))
  2176. hr = CreateBindCtx(0, &m_spBindCtx);
  2177. if (SUCCEEDED(hr))
  2178. hr = RegisterBindStatusCallback(m_spBindCtx, reinterpret_cast<IBindStatusCallback*>(static_cast<IBindStatusCallbackImpl<T>*>(this)), 0, 0L);
  2179. else
  2180. m_spMoniker.Release();
  2181. if (SUCCEEDED(hr))
  2182. hr = m_spMoniker->BindToStorage(m_spBindCtx, 0, IID_IStream, (void**)&spStream);
  2183. }
  2184. else
  2185. {
  2186. hr = CreateBindCtx(0, &m_spBindCtx);
  2187. if (SUCCEEDED(hr))
  2188. hr = RegisterBindStatusCallback(m_spBindCtx, reinterpret_cast<IBindStatusCallback*>(static_cast<IBindStatusCallbackImpl<T>*>(this)), 0, 0L);
  2189. if (SUCCEEDED(hr))
  2190. {
  2191. if (bRelative)
  2192. hr = spBindHost->CreateMoniker(bstrURL, m_spBindCtx, &m_spMoniker, 0);
  2193. else
  2194. hr = CreateURLMoniker(NULL, bstrURL, &m_spMoniker);
  2195. }
  2196. if (SUCCEEDED(hr))
  2197. {
  2198. hr = spBindHost->MonikerBindToStorage(m_spMoniker, NULL, reinterpret_cast<IBindStatusCallback*>(static_cast<IBindStatusCallbackImpl<T>*>(this)), IID_IStream, (void**)&spStream);
  2199. ATLTRACE(_T("Bound"));
  2200. }
  2201. }
  2202. return hr;
  2203. }
  2204. HRESULT StartAsyncDownload(T* pT, ATL_PDATAAVAILABLE pFunc, BSTR bstrURL, IUnknown* pUnkContainer = NULL, BOOL bRelative = FALSE)
  2205. {
  2206. m_pT = pT;
  2207. m_pFunc = pFunc;
  2208. return _StartAsyncDownload(bstrURL, pUnkContainer, bRelative);
  2209. }
  2210. static HRESULT Download(T* pT, ATL_PDATAAVAILABLE pFunc, BSTR bstrURL, IUnknown* pUnkContainer = NULL, BOOL bRelative = FALSE)
  2211. {
  2212. CComObject<CBindStatusCallback<T> > *pbsc;
  2213. HRESULT hRes = CComObject<CBindStatusCallback<T> >::CreateInstance(&pbsc);
  2214. if (FAILED(hRes))
  2215. return hRes;
  2216. return pbsc->StartAsyncDownload(pT, pFunc, bstrURL, pUnkContainer, bRelative);
  2217. }
  2218. CComPtr<IMoniker> m_spMoniker;
  2219. CComPtr<IBindCtx> m_spBindCtx;
  2220. CComPtr<IBinding> m_spBinding;
  2221. CComPtr<IStream> m_spStream;
  2222. T* m_pT;
  2223. ATL_PDATAAVAILABLE m_pFunc;
  2224. DWORD m_dwTotalRead;
  2225. DWORD m_dwAvailableToRead;
  2226. };
  2227. #define IMPLEMENT_STOCKPROP(type, fname, pname, dispid) \
  2228. HRESULT STDMETHODCALLTYPE put_##fname(type pname) \
  2229. { \
  2230. T* pT = (T*) this; \
  2231. if (pT->FireOnRequestEdit(dispid) == S_FALSE) \
  2232. return S_FALSE; \
  2233. pT->m_##pname = pname; \
  2234. pT->m_bRequiresSave = TRUE; \
  2235. pT->FireOnChanged(dispid); \
  2236. pT->FireViewChange(); \
  2237. return S_OK; \
  2238. } \
  2239. HRESULT STDMETHODCALLTYPE get_##fname(type* p##pname) \
  2240. { \
  2241. T* pT = (T*) this; \
  2242. *p##pname = pT->m_##pname; \
  2243. return S_OK; \
  2244. }
  2245. #define IMPLEMENT_BOOL_STOCKPROP(fname, pname, dispid) \
  2246. HRESULT STDMETHODCALLTYPE put_##fname(VARIANT_BOOL pname) \
  2247. { \
  2248. T* pT = (T*) this; \
  2249. if (pT->FireOnRequestEdit(dispid) == S_FALSE) \
  2250. return S_FALSE; \
  2251. pT->m_##pname = pname; \
  2252. pT->m_bRequiresSave = TRUE; \
  2253. pT->FireOnChanged(dispid); \
  2254. pT->FireViewChange(); \
  2255. return S_OK; \
  2256. } \
  2257. HRESULT STDMETHODCALLTYPE get_##fname(VARIANT_BOOL* p##pname) \
  2258. { \
  2259. T* pT = (T*) this; \
  2260. *p##pname = pT->m_##pname ? VARIANT_TRUE : VARIANT_FALSE; \
  2261. return S_OK; \
  2262. }
  2263. #define IMPLEMENT_BSTR_STOCKPROP(fname, pname, dispid) \
  2264. HRESULT STDMETHODCALLTYPE put_##fname(BSTR pname) \
  2265. { \
  2266. T* pT = (T*) this; \
  2267. if (pT->FireOnRequestEdit(dispid) == S_FALSE) \
  2268. return S_FALSE; \
  2269. *(&(pT->m_##pname)) = SysAllocString(pname); \
  2270. pT->m_bRequiresSave = TRUE; \
  2271. pT->FireOnChanged(dispid); \
  2272. pT->FireViewChange(); \
  2273. return S_OK; \
  2274. } \
  2275. HRESULT STDMETHODCALLTYPE get_##fname(BSTR* p##pname) \
  2276. { \
  2277. T* pT = (T*) this; \
  2278. *p##pname = SysAllocString(pT->m_##pname); \
  2279. return S_OK; \
  2280. }
  2281. template < class T, class InterfaceName, const IID* piid, const GUID* plibid>
  2282. class ATL_NO_VTABLE CStockPropImpl : public IDispatchImpl< InterfaceName, piid, plibid >
  2283. {
  2284. public:
  2285. // Font
  2286. HRESULT STDMETHODCALLTYPE put_Font(IFontDisp* pFont)
  2287. {
  2288. T* pT = (T*) this;
  2289. if (pT->FireOnRequestEdit(DISPID_FONT) == S_FALSE)
  2290. return S_FALSE;
  2291. pT->m_pFont = 0;
  2292. if (pFont)
  2293. {
  2294. CComQIPtr<IFont, &IID_IFont> p(pFont);
  2295. if (p)
  2296. {
  2297. CComPtr<IFont> pFont;
  2298. p->Clone(&pFont);
  2299. if (pFont)
  2300. pFont->QueryInterface(IID_IFontDisp, (void**) &pT->m_pFont);
  2301. }
  2302. }
  2303. pT->m_bRequiresSave = TRUE;
  2304. pT->FireOnChanged(DISPID_FONT);
  2305. pT->FireViewChange();
  2306. return S_OK;
  2307. }
  2308. HRESULT STDMETHODCALLTYPE putref_Font(IFontDisp* pFont)
  2309. {
  2310. T* pT = (T*) this;
  2311. if (pT->FireOnRequestEdit(DISPID_FONT) == S_FALSE)
  2312. return S_FALSE;
  2313. pT->m_pFont = pFont;
  2314. pT->m_bRequiresSave = TRUE;
  2315. pT->FireOnChanged(DISPID_FONT);
  2316. pT->FireViewChange();
  2317. return S_OK;
  2318. }
  2319. HRESULT STDMETHODCALLTYPE get_Font(IFontDisp** ppFont)
  2320. {
  2321. T* pT = (T*) this;
  2322. *ppFont = pT->m_pFont;
  2323. if (*ppFont != NULL)
  2324. (*ppFont)->AddRef();
  2325. return S_OK;
  2326. }
  2327. // Picture
  2328. HRESULT STDMETHODCALLTYPE put_Picture(IPictureDisp* pPicture)
  2329. {
  2330. T* pT = (T*) this;
  2331. if (pT->FireOnRequestEdit(DISPID_PICTURE) == S_FALSE)
  2332. return S_FALSE;
  2333. pT->m_pPicture = 0;
  2334. if (pPicture)
  2335. {
  2336. CComQIPtr<IPersistStream, &IID_IPersistStream> p(pPicture);
  2337. if (p)
  2338. {
  2339. ULARGE_INTEGER l;
  2340. p->GetSizeMax(&l);
  2341. HGLOBAL hGlob = GlobalAlloc(GHND, l.LowPart);
  2342. if (hGlob)
  2343. {
  2344. CComPtr<IStream> spStream;
  2345. CreateStreamOnHGlobal(hGlob, TRUE, &spStream);
  2346. if (spStream)
  2347. {
  2348. if (SUCCEEDED(p->Save(spStream, FALSE)))
  2349. {
  2350. LARGE_INTEGER l;
  2351. l.QuadPart = 0;
  2352. spStream->Seek(l, STREAM_SEEK_SET, NULL);
  2353. OleLoadPicture(spStream, l.LowPart, FALSE, IID_IPictureDisp, (void**)&pT->m_pPicture);
  2354. }
  2355. spStream.Release();
  2356. }
  2357. GlobalFree(hGlob);
  2358. }
  2359. }
  2360. }
  2361. pT->m_bRequiresSave = TRUE;
  2362. pT->FireOnChanged(DISPID_PICTURE);
  2363. pT->FireViewChange();
  2364. return S_OK;
  2365. }
  2366. HRESULT STDMETHODCALLTYPE putref_Picture(IPictureDisp* pPicture)
  2367. {
  2368. T* pT = (T*) this;
  2369. if (pT->FireOnRequestEdit(DISPID_PICTURE) == S_FALSE)
  2370. return S_FALSE;
  2371. pT->m_pPicture = pPicture;
  2372. pT->m_bRequiresSave = TRUE;
  2373. pT->FireOnChanged(DISPID_PICTURE);
  2374. pT->FireViewChange();
  2375. return S_OK;
  2376. }
  2377. HRESULT STDMETHODCALLTYPE get_Picture(IPictureDisp** ppPicture)
  2378. {
  2379. T* pT = (T*) this;
  2380. *ppPicture = pT->m_pPicture;
  2381. if (*ppPicture != NULL)
  2382. (*ppPicture)->AddRef();
  2383. return S_OK;
  2384. }
  2385. // MouseIcon
  2386. HRESULT STDMETHODCALLTYPE put_MouseIcon(IPictureDisp* pPicture)
  2387. {
  2388. T* pT = (T*) this;
  2389. if (pT->FireOnRequestEdit(DISPID_MOUSEICON) == S_FALSE)
  2390. return S_FALSE;
  2391. pT->m_pMouseIcon = 0;
  2392. if (pPicture)
  2393. {
  2394. CComQIPtr<IPersistStream, &IID_IPersistStream> p(pPicture);
  2395. if (p)
  2396. {
  2397. ULARGE_INTEGER l;
  2398. p->GetSizeMax(&l);
  2399. HGLOBAL hGlob = GlobalAlloc(GHND, l.LowPart);
  2400. if (hGlob)
  2401. {
  2402. CComPtr<IStream> spStream;
  2403. CreateStreamOnHGlobal(hGlob, TRUE, &spStream);
  2404. if (spStream)
  2405. {
  2406. if (SUCCEEDED(p->Save(spStream, FALSE)))
  2407. {
  2408. LARGE_INTEGER l;
  2409. l.QuadPart = 0;
  2410. spStream->Seek(l, STREAM_SEEK_SET, NULL);
  2411. OleLoadPicture(spStream, l.LowPart, FALSE, IID_IPictureDisp, (void**)&pT->m_pMouseIcon);
  2412. }
  2413. spStream.Release();
  2414. }
  2415. GlobalFree(hGlob);
  2416. }
  2417. }
  2418. }
  2419. pT->m_bRequiresSave = TRUE;
  2420. pT->FireOnChanged(DISPID_MOUSEICON);
  2421. pT->FireViewChange();
  2422. return S_OK;
  2423. }
  2424. HRESULT STDMETHODCALLTYPE putref_MouseIcon(IPictureDisp* pPicture)
  2425. {
  2426. T* pT = (T*) this;
  2427. if (pT->FireOnRequestEdit(DISPID_MOUSEICON) == S_FALSE)
  2428. return S_FALSE;
  2429. pT->m_pMouseIcon = pPicture;
  2430. pT->m_bRequiresSave = TRUE;
  2431. pT->FireOnChanged(DISPID_MOUSEICON);
  2432. pT->FireViewChange();
  2433. return S_OK;
  2434. }
  2435. HRESULT STDMETHODCALLTYPE get_MouseIcon(IPictureDisp** ppPicture)
  2436. {
  2437. T* pT = (T*) this;
  2438. *ppPicture = pT->m_pMouseIcon;
  2439. if (*ppPicture != NULL)
  2440. (*ppPicture)->AddRef();
  2441. return S_OK;
  2442. }
  2443. IMPLEMENT_STOCKPROP(OLE_COLOR, BackColor, clrBackColor, DISPID_BACKCOLOR)
  2444. IMPLEMENT_STOCKPROP(OLE_COLOR, BorderColor, clrBorderColor, DISPID_BORDERCOLOR)
  2445. IMPLEMENT_STOCKPROP(OLE_COLOR, FillColor, clrFillColor, DISPID_FILLCOLOR)
  2446. IMPLEMENT_STOCKPROP(OLE_COLOR, ForeColor, clrForeColor, DISPID_FORECOLOR)
  2447. IMPLEMENT_BOOL_STOCKPROP(AutoSize, bAutoSize, DISPID_AUTOSIZE)
  2448. IMPLEMENT_BOOL_STOCKPROP(Valid, bValid, DISPID_VALID)
  2449. IMPLEMENT_BOOL_STOCKPROP(Enabled, bEnabled, DISPID_ENABLED)
  2450. IMPLEMENT_BOOL_STOCKPROP(TabStop, bTabStop, DISPID_TABSTOP)
  2451. IMPLEMENT_BOOL_STOCKPROP(BorderVisible, bBorderVisible, DISPID_BORDERVISIBLE)
  2452. IMPLEMENT_BSTR_STOCKPROP(Text, bstrText, DISPID_TEXT)
  2453. IMPLEMENT_BSTR_STOCKPROP(Caption, bstrCaption, DISPID_CAPTION)
  2454. HRESULT STDMETHODCALLTYPE put_Window(LONG /*hWnd*/)
  2455. {
  2456. return E_FAIL;
  2457. }
  2458. HRESULT STDMETHODCALLTYPE get_Window(LONG* phWnd)
  2459. {
  2460. T* pT = (T*) this;
  2461. *phWnd = (LONG)(LONG_PTR)pT->m_hWnd;
  2462. return S_OK;
  2463. }
  2464. IMPLEMENT_STOCKPROP(long, BackStyle, nBackStyle, DISPID_BACKSTYLE)
  2465. IMPLEMENT_STOCKPROP(long, BorderStyle, nBorderStyle, DISPID_BORDERSTYLE)
  2466. IMPLEMENT_STOCKPROP(long, BorderWidth, nBorderWidth, DISPID_BORDERWIDTH)
  2467. IMPLEMENT_STOCKPROP(long, DrawMode, nDrawMode, DISPID_DRAWMODE)
  2468. IMPLEMENT_STOCKPROP(long, DrawStyle, nDrawStyle, DISPID_DRAWSTYLE)
  2469. IMPLEMENT_STOCKPROP(long, DrawWidth, nDrawWidth, DISPID_DRAWWIDTH)
  2470. IMPLEMENT_STOCKPROP(long, FillStyle, nFillStyle, DISPID_FILLSTYLE)
  2471. IMPLEMENT_STOCKPROP(long, Appearance, nAppearance, DISPID_APPEARANCE)
  2472. IMPLEMENT_STOCKPROP(long, MousePointer, nMousePointer, DISPID_MOUSEPOINTER)
  2473. IMPLEMENT_STOCKPROP(long, ReadyState, nReadyState, DISPID_READYSTATE)
  2474. };
  2475. #ifndef ATL_NO_NAMESPACE
  2476. }; //namespace ATL
  2477. #endif
  2478. #endif // __ATLCTL_H__