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.

177 lines
6.3 KiB

  1. #ifndef __IEMYPICS_H_
  2. #define __IEMYPICS_H_
  3. // other constants:
  4. #define MP_BMP_CX 16 // bitmap size
  5. #define MP_BMP_CY 16
  6. #define MP_NUM_TBBUTTONS 4 // number buttons
  7. #define MP_NUM_TBBITMAPS 4
  8. #define MP_MIN_CX 114 // minimum x size of toolbar
  9. #define MP_MIN_CY 28 // minimum y size of toolbar
  10. #define MP_MIN_SIZE 200 // minimum square size in pixels for hoverbar to appear
  11. #define MP_HOVER_OFFSET 10 // offset +x +y from (x,y) of image's upper lefthand corner
  12. #define MP_TIMER 700 // time in milliseconds to delay on the mouseover/out events
  13. #define MP_SCROLLBAR_SIZE GetSystemMetrics(SM_CXVSCROLL) // size of the scrollbars in pixels
  14. // e-mail picture stuff called via ITridentService2
  15. HRESULT DropOnMailRecipient(IDataObject *pdtobj, DWORD grfKeyState);
  16. HRESULT CreateShortcutSetSiteAndGetDataObjectIfPIDLIsNetUrl(LPCITEMIDLIST pidl, IUnknown *pUnkSite, IUniformResourceLocator **ppUrlOut, IDataObject **ppdtobj);
  17. HRESULT SendDocToMailRecipient(LPCITEMIDLIST pidl, UINT uiCodePage, DWORD grfKeyState, IUnknown *pUnkSite);
  18. // need this to get scroll event, it lives in iforms.cpp...
  19. void Win3FromDoc2(IHTMLDocument2 *pDoc2, IHTMLWindow3 **ppWin3);
  20. // well, yeah.
  21. BOOL MP_IsEnabledInRegistry();
  22. BOOL MP_IsEnabledInIEAK();
  23. DWORD MP_GetFilterInfoFromRegistry();
  24. // EventSink Callback Class (glorified array)...
  25. class CMyPicsEventSinkCallback
  26. {
  27. public:
  28. typedef enum
  29. {
  30. EVENT_BOGUS = 100,
  31. EVENT_MOUSEOVER = 0,
  32. EVENT_MOUSEOUT,
  33. EVENT_SCROLL,
  34. EVENT_RESIZE
  35. }
  36. EVENTS;
  37. typedef struct
  38. {
  39. EVENTS Event;
  40. LPCWSTR pwszEventSubscribe;
  41. LPCWSTR pwszEventName;
  42. }
  43. EventSinkEntry;
  44. virtual HRESULT HandleEvent(IHTMLElement *pEle, EVENTS Event, IHTMLEventObj *pEventObj) = 0;
  45. static EventSinkEntry EventsToSink[];
  46. };
  47. class CMyPics : public CMyPicsEventSinkCallback
  48. {
  49. long m_cRef;
  50. public:
  51. class CEventSink;
  52. CMyPics();
  53. ~CMyPics();
  54. // IUnknown...
  55. virtual STDMETHODIMP QueryInterface(REFIID, void **);
  56. virtual ULONG __stdcall AddRef();
  57. virtual ULONG __stdcall Release();
  58. // CMyPicsEventSinkCallback...
  59. HRESULT HandleEvent(IHTMLElement *pEle, EVENTS Event, IHTMLEventObj *pEventObj);
  60. HRESULT Init(IHTMLDocument2 *pDoc2);
  61. HRESULT UnInit();
  62. static HRESULT GetName(IHTMLInputTextElement *pTextEle, BSTR *pbstrName);
  63. static BOOL IsAdminRestricted(LPCTSTR pszRegVal);
  64. typedef HRESULT (*PFN_ENUM_CALLBACK)(IDispatch *pDispEle, DWORD_PTR dwCBData);
  65. BOOL IsOff();
  66. static VOID CALLBACK s_TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
  67. void IsGalleryMeta(BOOL bFlag);
  68. protected:
  69. // Methods for managing the Hover bar
  70. HRESULT CreateHover();
  71. HRESULT DestroyHover();
  72. HRESULT HideHover();
  73. HRESULT ShowHover();
  74. // Event handlers
  75. HRESULT HandleScroll();
  76. HRESULT HandleMouseout();
  77. HRESULT HandleMouseover(IHTMLElement *pEle);
  78. HRESULT HandleResize();
  79. static LRESULT CALLBACK s_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  80. LRESULT CALLBACK DisableWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  81. BOOL ShouldAppearOnThisElement(IHTMLElement *pEle);
  82. HRESULT GetRealCoords(IHTMLElement2 *pEle2, HWND hwnd, LONG *plLeft, LONG *plTop, LONG *plRight, LONG *plBottom);
  83. IHTMLElement *GetIMGFromArea(IHTMLElement *pEleIn, POINT ptEvent);
  84. private:
  85. // CMyPics member variables
  86. CEventSink *m_pSink;
  87. // Floating Toolbar stuff...
  88. HWND m_Hwnd, // Hwnd for the m_pdoc2
  89. m_hWndHover, // Hover rebar thing
  90. m_hWndMyPicsToolBar; // Toolbar that lives in the hover thing
  91. UINT m_hoverState; // Current state of the HoverBar thing
  92. UINT_PTR m_uidTimer; // The Timer
  93. WNDPROC m_wndprocOld; // For stuff
  94. HIMAGELIST m_himlHover; // For the image list
  95. HIMAGELIST m_himlHoverHot; // for the hot images
  96. // Useful stuff for the attached document
  97. IHTMLDocument2 *m_pDoc2;
  98. IHTMLElement *m_pEleCurr; // current element we are hovering over
  99. IHTMLWindow3 *m_pWin3; // for unsinking scroll event
  100. EVENTS m_eventsCurr; // event currently being processed
  101. BOOL m_bIsOffForSession : 1; // have we disabled feature for this session?
  102. BOOL m_bGalleryMeta : 1; // TRUE if there was a META tag disabling image bar for this doc
  103. BOOL m_bGalleryImg : 1; // TRUE if the current element has a galleryimg value set to TRUE
  104. public:
  105. // Sinks regular Trident events. Calls back via CMyPicsEventSinkCallback...
  106. class CEventSink : public IDispatch
  107. {
  108. ULONG m_cRef;
  109. public:
  110. CEventSink(CMyPicsEventSinkCallback *pParent);
  111. ~CEventSink();
  112. HRESULT SinkEvents(IHTMLElement2 *pEle2, int iNum, EVENTS *pEvents);
  113. HRESULT UnSinkEvents(IHTMLElement2 *pEle2, int iNum, EVENTS *pEvents);
  114. HRESULT SinkEvents(IHTMLWindow3 *pWin3, int iNum, EVENTS *pEvents);
  115. HRESULT UnSinkEvents(IHTMLWindow3 *pWin3, int iNum, EVENTS *pEvents);
  116. void SetParent(CMyPicsEventSinkCallback *pParent) { m_pParent = pParent; }
  117. STDMETHODIMP QueryInterface(REFIID, void **);
  118. STDMETHODIMP_(ULONG) AddRef(void);
  119. STDMETHODIMP_(ULONG) Release(void);
  120. // IDispatch
  121. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
  122. STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo);
  123. STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames,
  124. LCID lcid, DISPID *rgDispId);
  125. STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid,
  126. LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
  127. EXCEPINFO *pExcepInfo, UINT *puArgErr);
  128. private:
  129. CMyPicsEventSinkCallback *m_pParent;
  130. };
  131. };
  132. #endif //__IEMYPICS_H_