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.

161 lines
5.7 KiB

  1. #ifndef __IEAIRESIZE_H_
  2. #define __IEAIRESIZE_H_
  3. #define AIR_SCREEN_CONSTANTY 34 // in pixels (this is a magic number)
  4. #define AIR_SCREEN_CONSTANTX 40 // in pixels (this is a magic number)
  5. #define AIR_TIMER 1400 // time in milliseconds to delay on mouseover/out events
  6. #define AIR_MIN_CX 39 // minimum x size of the button
  7. #define AIR_MIN_CY 38 // minimum y size of the button
  8. #define AIR_NUM_TBBITMAPS 1 // number of bitmaps (only 1 button)
  9. #define AIR_BMP_CX 32 // bitmap size
  10. #define AIR_BMP_CY 32
  11. #define AIR_MIN_BROWSER_SIZE 150 // min size in pixels the browser has to be to display the button
  12. #define AIR_SCROLLBAR_SIZE_V GetSystemMetrics(SM_CXVSCROLL)
  13. #define AIR_SCROLLBAR_SIZE_H GetSystemMetrics(SM_CYHSCROLL)
  14. // used for sinking scroll events:
  15. void Win3FromDoc2(IHTMLDocument2 *pDoc2, IHTMLWindow3 **ppWin3);
  16. DWORD MP_GetOffsetInfoFromRegistry();
  17. // EventSink Callback Class...
  18. class CAutoImageResizeEventSinkCallback
  19. {
  20. public:
  21. typedef enum
  22. {
  23. EVENT_BOGUS = 100,
  24. EVENT_MOUSEOVER = 0,
  25. EVENT_MOUSEOUT,
  26. EVENT_SCROLL,
  27. EVENT_RESIZE,
  28. EVENT_BEFOREPRINT,
  29. EVENT_AFTERPRINT
  30. }
  31. EVENTS;
  32. typedef struct
  33. {
  34. EVENTS Event;
  35. LPCWSTR pwszEventSubscribe;
  36. LPCWSTR pwszEventName;
  37. }
  38. EventSinkEntry;
  39. virtual HRESULT HandleEvent(IHTMLElement *pEle, EVENTS Event, IHTMLEventObj *pEventObj) = 0;
  40. static EventSinkEntry EventsToSink[];
  41. };
  42. class CAutoImageResize : public CAutoImageResizeEventSinkCallback
  43. {
  44. long m_cRef;
  45. public:
  46. class CEventSink;
  47. CAutoImageResize();
  48. ~CAutoImageResize();
  49. // IUnknown...
  50. virtual STDMETHODIMP QueryInterface(REFIID, void **);
  51. virtual ULONG __stdcall AddRef();
  52. virtual ULONG __stdcall Release();
  53. // CAutoImageResizeEventSinkCallback...
  54. HRESULT HandleEvent(IHTMLElement *pEle, EVENTS Event, IHTMLEventObj *pEventObj);
  55. // Init and UnInit (called from basesb.cpp)
  56. HRESULT Init(IHTMLDocument2 *pDoc2);
  57. HRESULT UnInit();
  58. protected:
  59. // AutoImageResize Stuff
  60. HRESULT DoAutoImageResize();
  61. // Event Handlers
  62. HRESULT HandleMouseover();
  63. HRESULT HandleMouseout();
  64. HRESULT HandleScroll();
  65. HRESULT HandleResize();
  66. HRESULT HandleBeforePrint();
  67. HRESULT HandleAfterPrint();
  68. // Button Functions
  69. HRESULT CreateButton();
  70. HRESULT ShowButton();
  71. HRESULT HideButton();
  72. HRESULT DestroyButton();
  73. // Timer callback function
  74. static VOID CALLBACK s_TimerProc(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime);
  75. // Button callback function
  76. static LRESULT CALLBACK s_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  77. private:
  78. // CAutoImageResize member variables
  79. CEventSink *m_pSink; // Event Sink
  80. HWND m_hWndButton; // Button hWnd
  81. HWND m_hWndButtonCont;
  82. WNDPROC m_wndProcOld; // Old wind proc for button
  83. HIMAGELIST m_himlButtonShrink; // Shrink image
  84. HIMAGELIST m_himlButtonExpand; // Expand image
  85. UINT m_airState; // Current state of the AutoImageResize feature (image state)
  86. UINT m_airButtonState; // Current state of the AIR Button
  87. UINT m_airUsersLastChoice; // The last state the user put us into by clicking the button
  88. UINT m_airBeforePrintState; // OnAfterPrint uses this to restore state if necessary
  89. POINT m_airOrigSize; // Original x,y dimensions of an image thats been AIR'ed
  90. BOOL m_bWindowResizing; // True when a onresize event for the win3 object fired, but hasn't been processed yet.
  91. // Useful stuff for the attached document
  92. HWND m_hWnd; // Browser hWnd
  93. IHTMLDocument2 *m_pDoc2; // Document pointer
  94. IHTMLElement2 *m_pEle2; // Pointer to the image
  95. IHTMLWindow3 *m_pWin3; // For unsinking scroll event
  96. EVENTS m_eventsCurr; // Event currently being processed
  97. public:
  98. // Sinks regular Trident events. Calls back via CAutoImageResizeEventSinkCallback...
  99. class CEventSink : public IDispatch
  100. {
  101. ULONG m_cRef;
  102. public:
  103. CEventSink(CAutoImageResizeEventSinkCallback *pParent);
  104. ~CEventSink();
  105. HRESULT SinkEvents(IHTMLElement2 *pEle2, int iNum, EVENTS *pEvents);
  106. HRESULT UnSinkEvents(IHTMLElement2 *pEle2, int iNum, EVENTS *pEvents);
  107. HRESULT SinkEvents(IHTMLWindow3 *pWin3, int iNum, EVENTS *pEvents);
  108. HRESULT UnSinkEvents(IHTMLWindow3 *pWin3, int iNum, EVENTS *pEvents);
  109. void SetParent(CAutoImageResizeEventSinkCallback *pParent) { m_pParent = pParent; }
  110. STDMETHODIMP QueryInterface(REFIID, void **);
  111. STDMETHODIMP_(ULONG) AddRef(void);
  112. STDMETHODIMP_(ULONG) Release(void);
  113. // IDispatch
  114. STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
  115. STDMETHODIMP GetTypeInfo(UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo);
  116. STDMETHODIMP GetIDsOfNames(REFIID riid, LPOLESTR *rgszNames, UINT cNames,
  117. LCID lcid, DISPID *rgDispId);
  118. STDMETHODIMP Invoke(DISPID dispIdMember, REFIID riid,
  119. LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
  120. EXCEPINFO *pExcepInfo, UINT *puArgErr);
  121. private:
  122. CAutoImageResizeEventSinkCallback *m_pParent;
  123. };
  124. };
  125. #endif //__IEAIRESIZE_H_