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

ActiveX/DCOM/ATL

开发平台:

Visual C++

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