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

ActiveX/DCOM/ATL

开发平台:

Visual C++

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