MyAbcd.h
上传用户:weisheen
上传日期:2022-07-09
资源大小:19390k
文件大小:3k
源码类别:

ActiveX/DCOM/ATL

开发平台:

Visual C++

  1. // MyAbcd.h : Declaration of the CMyAbcd
  2. #ifndef __MYABCD_H_
  3. #define __MYABCD_H_
  4. #include "resource.h"       // main symbols
  5. #include <atlctl.h>
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CMyAbcd
  8. class ATL_NO_VTABLE CMyAbcd : 
  9. public CComObjectRootEx<CComSingleThreadModel>,
  10. public IDispatchImpl<IMyAbcd, &IID_IMyAbcd, &LIBID_EXEVENTLib>,
  11. public CComCompositeControl<CMyAbcd>,
  12. public IPersistStreamInitImpl<CMyAbcd>,
  13. public IOleControlImpl<CMyAbcd>,
  14. public IOleObjectImpl<CMyAbcd>,
  15. public IOleInPlaceActiveObjectImpl<CMyAbcd>,
  16. public IViewObjectExImpl<CMyAbcd>,
  17. public IOleInPlaceObjectWindowlessImpl<CMyAbcd>,
  18. public IConnectionPointContainerImpl<CMyAbcd>,
  19. public IPersistStorageImpl<CMyAbcd>,
  20. public ISpecifyPropertyPagesImpl<CMyAbcd>,
  21. public IQuickActivateImpl<CMyAbcd>,
  22. public IDataObjectImpl<CMyAbcd>,
  23. public IProvideClassInfo2Impl<&CLSID_MyAbcd, &DIID__IMyAbcdEvents, &LIBID_EXEVENTLib>,
  24. public IPropertyNotifySinkCP<CMyAbcd>,
  25. public CComCoClass<CMyAbcd, &CLSID_MyAbcd>
  26. {
  27. public:
  28. CMyAbcd()
  29. {
  30. m_bWindowOnly = TRUE;
  31. CalcExtent(m_sizeExtent);
  32. }
  33. DECLARE_REGISTRY_RESOURCEID(IDR_MYABCD)
  34. DECLARE_PROTECT_FINAL_CONSTRUCT()
  35. BEGIN_COM_MAP(CMyAbcd)
  36. COM_INTERFACE_ENTRY(IMyAbcd)
  37. COM_INTERFACE_ENTRY(IDispatch)
  38. COM_INTERFACE_ENTRY(IViewObjectEx)
  39. COM_INTERFACE_ENTRY(IViewObject2)
  40. COM_INTERFACE_ENTRY(IViewObject)
  41. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  42. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  43. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  44. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  45. COM_INTERFACE_ENTRY(IOleControl)
  46. COM_INTERFACE_ENTRY(IOleObject)
  47. COM_INTERFACE_ENTRY(IPersistStreamInit)
  48. COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
  49. COM_INTERFACE_ENTRY(IConnectionPointContainer)
  50. COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
  51. COM_INTERFACE_ENTRY(IQuickActivate)
  52. COM_INTERFACE_ENTRY(IPersistStorage)
  53. COM_INTERFACE_ENTRY(IDataObject)
  54. COM_INTERFACE_ENTRY(IProvideClassInfo)
  55. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  56. END_COM_MAP()
  57. BEGIN_PROP_MAP(CMyAbcd)
  58. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  59. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  60. // Example entries
  61. // PROP_ENTRY("Property Description", dispid, clsid)
  62. // PROP_PAGE(CLSID_StockColorPage)
  63. END_PROP_MAP()
  64. BEGIN_CONNECTION_POINT_MAP(CMyAbcd)
  65. CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
  66. END_CONNECTION_POINT_MAP()
  67. BEGIN_MSG_MAP(CMyAbcd)
  68. CHAIN_MSG_MAP(CComCompositeControl<CMyAbcd>)
  69. END_MSG_MAP()
  70. // Handler prototypes:
  71. //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  72. //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  73. //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  74. BEGIN_SINK_MAP(CMyAbcd)
  75. //Make sure the Event Handlers have __stdcall calling convention
  76. END_SINK_MAP()
  77. STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
  78. {
  79. if (dispid == DISPID_AMBIENT_BACKCOLOR)
  80. {
  81. SetBackgroundColorFromAmbient();
  82. FireViewChange();
  83. }
  84. return IOleControlImpl<CMyAbcd>::OnAmbientPropertyChange(dispid);
  85. }
  86. // IViewObjectEx
  87. DECLARE_VIEW_STATUS(0)
  88. // IMyAbcd
  89. public:
  90. enum { IDD = IDD_MYABCD };
  91. };
  92. #endif //__MYABCD_H_