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

ActiveX/DCOM/ATL

开发平台:

Visual C++

  1. // MyPwds.h : Declaration of the CMyPwds
  2. #ifndef __MYPWDS_H_
  3. #define __MYPWDS_H_
  4. #include "resource.h"       // main symbols
  5. #include <atlctl.h>
  6. #include "EventCP.h"
  7. /////////////////////////////////////////////////////////////////////////////
  8. // CMyPwds
  9. class ATL_NO_VTABLE CMyPwds : 
  10. public CComObjectRootEx<CComSingleThreadModel>,
  11. public IDispatchImpl<IMyPwds, &IID_IMyPwds, &LIBID_EVENTLib>,
  12. public CComCompositeControl<CMyPwds>,
  13. public IPersistStreamInitImpl<CMyPwds>,
  14. public IOleControlImpl<CMyPwds>,
  15. public IOleObjectImpl<CMyPwds>,
  16. public IOleInPlaceActiveObjectImpl<CMyPwds>,
  17. public IViewObjectExImpl<CMyPwds>,
  18. public IOleInPlaceObjectWindowlessImpl<CMyPwds>,
  19. public IConnectionPointContainerImpl<CMyPwds>,
  20. public IPersistStorageImpl<CMyPwds>,
  21. public ISpecifyPropertyPagesImpl<CMyPwds>,
  22. public IQuickActivateImpl<CMyPwds>,
  23. public IDataObjectImpl<CMyPwds>,
  24. public IProvideClassInfo2Impl<&CLSID_MyPwds, &DIID__IMyPwdsEvents, &LIBID_EVENTLib>,
  25. public IPropertyNotifySinkCP<CMyPwds>,
  26. public CComCoClass<CMyPwds, &CLSID_MyPwds>,
  27. public CProxy_IMyPwdsEvents< CMyPwds >
  28. {
  29. public:
  30. CMyPwds()
  31. {
  32. m_bWindowOnly = TRUE;
  33. CalcExtent(m_sizeExtent);
  34. }
  35. DECLARE_REGISTRY_RESOURCEID(IDR_MYPWDS)
  36. DECLARE_PROTECT_FINAL_CONSTRUCT()
  37. BEGIN_COM_MAP(CMyPwds)
  38. COM_INTERFACE_ENTRY(IMyPwds)
  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(CMyPwds)
  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(CMyPwds)
  68. CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
  69. CONNECTION_POINT_ENTRY(DIID__IMyPwdsEvents)
  70. END_CONNECTION_POINT_MAP()
  71. BEGIN_MSG_MAP(CMyPwds)
  72. CHAIN_MSG_MAP(CComCompositeControl<CMyPwds>)
  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(CMyPwds)
  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<CMyPwds>::OnAmbientPropertyChange(dispid);
  90. }
  91. // IViewObjectEx
  92. DECLARE_VIEW_STATUS(0)
  93. // IMyPwds
  94. public:
  95. enum { IDD = IDD_MYPWDS };
  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 //__MYPWDS_H_