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.

106 lines
3.0 KiB

  1. // DeviceIcon.h : Declaration of the CDeviceIcon
  2. #ifndef __DEVICEICON_H_
  3. #define __DEVICEICON_H_
  4. #include "resource.h" // main symbols
  5. #include <atlctl.h>
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CDeviceIcon
  8. class ATL_NO_VTABLE CDeviceIcon :
  9. public CComObjectRootEx<CComSingleThreadModel>,
  10. public IDispatchImpl<IDeviceIcon, &IID_IDeviceIcon, &LIBID_DEVCON2Lib>,
  11. public CComControl<CDeviceIcon>,
  12. public IPersistStreamInitImpl<CDeviceIcon>,
  13. public IOleControlImpl<CDeviceIcon>,
  14. public IOleObjectImpl<CDeviceIcon>,
  15. public IOleInPlaceActiveObjectImpl<CDeviceIcon>,
  16. public IViewObjectExImpl<CDeviceIcon>,
  17. public IOleInPlaceObjectWindowlessImpl<CDeviceIcon>,
  18. public IPersistStorageImpl<CDeviceIcon>,
  19. public ISpecifyPropertyPagesImpl<CDeviceIcon>,
  20. public IQuickActivateImpl<CDeviceIcon>,
  21. public IDataObjectImpl<CDeviceIcon>,
  22. public IProvideClassInfo2Impl<&CLSID_DeviceIcon, NULL, &LIBID_DEVCON2Lib>,
  23. public CComCoClass<CDeviceIcon, &CLSID_DeviceIcon>
  24. {
  25. protected:
  26. HICON m_hIcon;
  27. HBITMAP m_hSmallImage;
  28. HBITMAP m_hSmallMask;
  29. INT m_MiniIcon;
  30. public:
  31. CDeviceIcon()
  32. {
  33. m_hIcon = NULL;
  34. m_MiniIcon = 0;
  35. m_hSmallImage = NULL;
  36. m_hSmallMask = NULL;
  37. }
  38. ~CDeviceIcon()
  39. {
  40. ResetIcon();
  41. }
  42. DECLARE_REGISTRY_RESOURCEID(IDR_DEVICEICON)
  43. DECLARE_PROTECT_FINAL_CONSTRUCT()
  44. BEGIN_COM_MAP(CDeviceIcon)
  45. COM_INTERFACE_ENTRY(IDeviceIcon)
  46. COM_INTERFACE_ENTRY(IDispatch)
  47. COM_INTERFACE_ENTRY(IViewObjectEx)
  48. COM_INTERFACE_ENTRY(IViewObject2)
  49. COM_INTERFACE_ENTRY(IViewObject)
  50. COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
  51. COM_INTERFACE_ENTRY(IOleInPlaceObject)
  52. COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
  53. COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
  54. COM_INTERFACE_ENTRY(IOleControl)
  55. COM_INTERFACE_ENTRY(IOleObject)
  56. COM_INTERFACE_ENTRY(IPersistStreamInit)
  57. COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
  58. COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
  59. COM_INTERFACE_ENTRY(IQuickActivate)
  60. COM_INTERFACE_ENTRY(IPersistStorage)
  61. COM_INTERFACE_ENTRY(IDataObject)
  62. COM_INTERFACE_ENTRY(IProvideClassInfo)
  63. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  64. END_COM_MAP()
  65. public:
  66. BEGIN_PROP_MAP(CDeviceIcon)
  67. PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
  68. PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
  69. // Example entries
  70. // PROP_ENTRY("Property Description", dispid, clsid)
  71. // PROP_PAGE(CLSID_StockColorPage)
  72. END_PROP_MAP()
  73. BEGIN_MSG_MAP(CDeviceIcon)
  74. CHAIN_MSG_MAP(CComControl<CDeviceIcon>)
  75. DEFAULT_REFLECTION_HANDLER()
  76. END_MSG_MAP()
  77. // Handler prototypes:
  78. // LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
  79. // LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
  80. // LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);
  81. HRESULT OnDraw(ATL_DRAWINFO& di);
  82. // IViewObjectEx
  83. DECLARE_VIEW_STATUS(0)
  84. // IDeviceIcon
  85. public:
  86. BOOL DrawMiniIcon(HDC hDC,RECT & rect,INT icon);
  87. STDMETHOD(ObtainIcon)(/*[in]*/ LPDISPATCH pSource);
  88. void ResetIcon();
  89. };
  90. #endif //__DEVICEICON_H_