Leaked source code of windows server 2003
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.

154 lines
5.5 KiB

  1. // ThumbCtl.h : Declaration of the CThumbCtl
  2. #ifndef __THUMBCTL_H_
  3. #define __THUMBCTL_H_
  4. #define WM_HTML_BITMAP (WM_USER + 100)
  5. EXTERN_C const CLSID CLSID_ThumbCtlOld; // retired from service
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CThumbCtl
  8. class ATL_NO_VTABLE CThumbCtl :
  9. public CComObjectRootEx<CComSingleThreadModel>,
  10. public CComCoClass<CThumbCtl, &CLSID_ThumbCtl>,
  11. public CComControl<CThumbCtl>,
  12. public IDispatchImpl<IThumbCtl, &IID_IThumbCtl, &LIBID_WEBVWLib>,
  13. public IProvideClassInfo2Impl<&CLSID_ThumbCtl, NULL, &LIBID_WEBVWLib>,
  14. public IPersistStreamInitImpl<CThumbCtl>,
  15. public IPersistStorageImpl<CThumbCtl>,
  16. public IQuickActivateImpl<CThumbCtl>,
  17. public IOleControlImpl<CThumbCtl>,
  18. public IOleObjectImpl<CThumbCtl>,
  19. public IOleInPlaceActiveObjectImpl<CThumbCtl>,
  20. public IViewObjectExImpl<CThumbCtl>,
  21. public IOleInPlaceObjectWindowlessImpl<CThumbCtl>,
  22. public IDataObjectImpl<CThumbCtl>,
  23. public ISupportErrorInfo,
  24. public ISpecifyPropertyPagesImpl<CThumbCtl>,
  25. public IObjectSafetyImpl<CThumbCtl, INTERFACESAFE_FOR_UNTRUSTED_CALLER>,
  26. public IConnectionPointImpl<CThumbCtl, &DIID_DThumbCtlEvents>,
  27. public IConnectionPointContainerImpl<CThumbCtl>
  28. {
  29. public:
  30. // === INTERFACE ===
  31. // *** IThumbCtl ***
  32. STDMETHOD(displayFile)(BSTR bsFileName, VARIANT_BOOL *);
  33. STDMETHOD(haveThumbnail)(VARIANT_BOOL *);
  34. STDMETHOD(get_freeSpace)(BSTR *);
  35. STDMETHOD(get_usedSpace)(BSTR *);
  36. STDMETHOD(get_totalSpace)(BSTR *);
  37. // ATL Functions
  38. // Drawing function
  39. HRESULT OnDraw(ATL_DRAWINFO& di);
  40. DECLARE_REGISTRY_RESOURCEID(IDR_THUMBCTL)
  41. BEGIN_COM_MAP(CThumbCtl)
  42. COM_INTERFACE_ENTRY(IThumbCtl)
  43. COM_INTERFACE_ENTRY(IDispatch)
  44. COM_INTERFACE_ENTRY(IObjectSafety)
  45. COM_INTERFACE_ENTRY_IMPL(IViewObjectEx)
  46. COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject2, IViewObjectEx)
  47. COM_INTERFACE_ENTRY_IMPL_IID(IID_IViewObject, IViewObjectEx)
  48. COM_INTERFACE_ENTRY_IMPL(IOleInPlaceObjectWindowless)
  49. COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleInPlaceObject, IOleInPlaceObjectWindowless)
  50. COM_INTERFACE_ENTRY_IMPL_IID(IID_IOleWindow, IOleInPlaceObjectWindowless)
  51. COM_INTERFACE_ENTRY_IMPL(IOleInPlaceActiveObject)
  52. COM_INTERFACE_ENTRY_IMPL(IOleControl)
  53. COM_INTERFACE_ENTRY_IMPL(IOleObject)
  54. COM_INTERFACE_ENTRY_IMPL(IQuickActivate)
  55. COM_INTERFACE_ENTRY_IMPL(IPersistStorage)
  56. COM_INTERFACE_ENTRY_IMPL(IPersistStreamInit)
  57. COM_INTERFACE_ENTRY_IMPL(ISpecifyPropertyPages)
  58. COM_INTERFACE_ENTRY_IMPL(IDataObject)
  59. COM_INTERFACE_ENTRY(IProvideClassInfo)
  60. COM_INTERFACE_ENTRY(IProvideClassInfo2)
  61. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  62. COM_INTERFACE_ENTRY_IMPL(IConnectionPointContainer)
  63. END_COM_MAP()
  64. BEGIN_CONNECTION_POINT_MAP(CThumbCtl)
  65. CONNECTION_POINT_ENTRY(DIID_DThumbCtlEvents)
  66. END_CONNECTION_POINT_MAP()
  67. BEGIN_PROPERTY_MAP(CThumbCtl)
  68. END_PROPERTY_MAP()
  69. BEGIN_MSG_MAP(CThumbCtl)
  70. MESSAGE_HANDLER(WM_PAINT, OnPaint)
  71. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  72. MESSAGE_HANDLER(WM_KILLFOCUS, OnKillFocus)
  73. END_MSG_MAP()
  74. // *** IObjectSafety ***
  75. STDMETHOD(GetInterfaceSafetyOptions)(REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions);
  76. // *** ISupportsErrorInfo ***
  77. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  78. // *** IViewObjectEx ***
  79. STDMETHOD(GetViewStatus)(DWORD* pdwStatus);
  80. // *** IOleInPlaceActiveObject ***
  81. virtual STDMETHODIMP TranslateAccelerator(LPMSG pMsg);
  82. public:
  83. // === PUBLIC FUNCTIONS ===
  84. CThumbCtl(void);
  85. ~CThumbCtl(void);
  86. private:
  87. // === PRIVATE DATA ===
  88. BOOL m_fRootDrive; // Do we have a root drive? (if so, display pie chart)
  89. BOOL m_fTabRecieved; // To avoid re-entrant calls
  90. // thumbnail
  91. BOOL m_fInitThumb; // Have we called the setup IThumbnail yet?
  92. BOOL m_fHaveIThumbnail; // success of SetupIThumbnail() (only call it once)
  93. IThumbnail *m_pthumb; // File to bitmap convertor interface
  94. HWND m_hwnd; // invisible window used to receive WM_HTML_BITMAP message
  95. HBITMAP m_hbm; // latest calculated bitmap; NULL if have no bitmap
  96. DWORD m_dwThumbnailID; // ID to identify which bitmap we received
  97. // root drive
  98. enum
  99. {
  100. PIE_USEDCOLOR = 0,
  101. PIE_FREECOLOR,
  102. PIE_USEDSHADOW,
  103. PIE_FREESHADOW,
  104. PIE_NUM // keep track of number of PIE_ values
  105. };
  106. DWORDLONG m_dwlFreeSpace;
  107. DWORDLONG m_dwlUsedSpace;
  108. DWORDLONG m_dwlTotalSpace;
  109. DWORD m_dwUsedSpacePer1000; // amount of used space /1000
  110. COLORREF m_acrChartColors[PIE_NUM]; // color scheme
  111. BOOL m_fUseSystemColors; // Use system color scheme?
  112. // === PRIVATE FUNCTIONS ===
  113. void InvokeOnThumbnailReady(void);
  114. // For the pie-chart drawing routines...
  115. HRESULT ComputeFreeSpace(LPTSTR pszFileName);
  116. HRESULT get_GeneralSpace(DWORDLONG dwlSpace, BSTR *);
  117. HRESULT Draw3dPie(HDC, LPRECT, DWORD dwPer1000, const COLORREF *);
  118. // security
  119. HRESULT _IsSafe()
  120. {
  121. return (0==m_dwCurrentSafety) ? S_OK : IsSafePage(m_spClientSite);
  122. };
  123. // sets up the thumbnail interface -- must call before use.
  124. HRESULT SetupIThumbnail(void);
  125. // Window Procedure for catching and storing bitmap
  126. static LRESULT CALLBACK WndProc(HWND, UINT uMsg, WPARAM, LPARAM);
  127. };
  128. #endif //__THUMBCTL_H_