1
0

HTMLContainer.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #ifndef NULLSOFT_HTMLCONTAINERH
  2. #define NULLSOFT_HTMLCONTAINERH
  3. #include <ocidl.h>
  4. #include <mshtmhst.h>
  5. #include <mshtmdid.h>
  6. #include <shlobj.h>
  7. /**************************************************************************
  8. class definitions
  9. **************************************************************************/
  10. #ifndef DOCHOSTUIFLAG_HOST_NAVIGATES
  11. #define DOCHOSTUIFLAG_HOST_NAVIGATES 0x02000000
  12. #endif
  13. #ifndef DOCHOSTUIFLAG_ENABLE_REDIRECT_NOTIFICATION
  14. #define DOCHOSTUIFLAG_ENABLE_REDIRECT_NOTIFICATION 0x04000000
  15. #endif
  16. #ifndef DOCHOSTUIFLAG_USE_WINDOWLESS_SELECTCONTROL
  17. #define DOCHOSTUIFLAG_USE_WINDOWLESS_SELECTCONTROL 0x08000000
  18. #endif
  19. #ifndef DOCHOSTUIFLAG_USE_WINDOWED_SELECTCONTROL
  20. #define DOCHOSTUIFLAG_USE_WINDOWED_SELECTCONTROL 0x10000000
  21. #endif
  22. #ifndef DOCHOSTUIFLAG_ENABLE_ACTIVEX_INACTIVATE_MODE
  23. #define DOCHOSTUIFLAG_ENABLE_ACTIVEX_INACTIVATE_MODE 0x20000000
  24. #endif
  25. class HTMLContainer : public IOleClientSite,
  26. public IOleInPlaceSite,
  27. public IOleInPlaceFrame,
  28. public IOleControlSite,
  29. public IDocHostUIHandler,
  30. public IDispatch
  31. {
  32. protected:
  33. ULONG m_cRefs; // ref count
  34. IUnknown *m_punk; // IUnknown of contained object
  35. RECT m_rect; // size of control
  36. bool bInitialized;
  37. public:
  38. HWND m_hwnd; // window handle of the container
  39. HTMLContainer();
  40. HTMLContainer(HWND hwnd);
  41. virtual ~HTMLContainer();
  42. public:
  43. // *** IUnknown Methods ***
  44. STDMETHOD(QueryInterface)(REFIID riid, PVOID *ppvObject);
  45. STDMETHOD_(ULONG, AddRef)(void);
  46. STDMETHOD_(ULONG, Release)(void);
  47. // *** IOleInPlaceUIWindow Methods ***
  48. STDMETHOD (GetBorder)(LPRECT lprectBorder);
  49. STDMETHOD (RequestBorderSpace)(LPCBORDERWIDTHS lpborderwidths);
  50. STDMETHOD (SetBorderSpace)(LPCBORDERWIDTHS lpborderwidths);
  51. STDMETHOD (SetActiveObject)(IOleInPlaceActiveObject * pActiveObject,
  52. LPCOLESTR lpszObjName);
  53. // *** IOleClientSite Methods ***
  54. STDMETHOD (SaveObject)();
  55. STDMETHOD (GetMoniker)(DWORD dwAssign, DWORD dwWhichMoniker, LPMONIKER *ppMk);
  56. STDMETHOD (GetContainer)(LPOLECONTAINER *ppContainer);
  57. STDMETHOD (ShowObject)();
  58. STDMETHOD (OnShowWindow)(BOOL fShow);
  59. STDMETHOD (RequestNewObjectLayout)();
  60. // *** IOleWindow Methods ***
  61. STDMETHOD (GetWindow) (HWND * phwnd);
  62. STDMETHOD (ContextSensitiveHelp) (BOOL fEnterMode);
  63. // *** IOleInPlaceSite Methods ***
  64. STDMETHOD (CanInPlaceActivate) (void);
  65. STDMETHOD (OnInPlaceActivate) (void);
  66. STDMETHOD (OnUIActivate) (void);
  67. STDMETHOD (GetWindowContext) (IOleInPlaceFrame ** ppFrame, IOleInPlaceUIWindow ** ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo);
  68. STDMETHOD (Scroll) (SIZE scrollExtent);
  69. STDMETHOD (OnUIDeactivate) (BOOL fUndoable);
  70. STDMETHOD (OnInPlaceDeactivate) (void);
  71. STDMETHOD (DiscardUndoState) (void);
  72. STDMETHOD (DeactivateAndUndo) (void);
  73. STDMETHOD (OnPosRectChange) (LPCRECT lprcPosRect);
  74. // *** IOleInPlaceFrame Methods ***
  75. STDMETHOD (InsertMenus)(HMENU hmenuShared, LPOLEMENUGROUPWIDTHS lpMenuWidths);
  76. STDMETHOD (SetMenu)(HMENU hmenuShared, HOLEMENU holemenu, HWND hwndActiveObject);
  77. STDMETHOD (RemoveMenus)(HMENU hmenuShared);
  78. STDMETHOD (SetStatusText)(LPCOLESTR pszStatusText);
  79. STDMETHOD (EnableModeless)(BOOL fEnable);
  80. STDMETHOD (TranslateAccelerator)(LPMSG lpmsg, WORD wID);
  81. // *** IOleControlSite Methods ***
  82. STDMETHOD (OnControlInfoChanged)(void);
  83. STDMETHOD (LockInPlaceActive)(BOOL fLock);
  84. STDMETHOD (GetExtendedControl)(IDispatch **ppDisp);
  85. STDMETHOD (TransformCoords)(POINTL *pptlHimetric, POINTF *pptfContainer, DWORD dwFlags);
  86. STDMETHOD (TranslateAccelerator)(LPMSG pMsg, DWORD grfModifiers);
  87. STDMETHOD (OnFocus)(BOOL fGotFocus);
  88. STDMETHOD (ShowPropertyFrame)(void);
  89. // *** IDispatch Methods ***
  90. STDMETHOD (GetIDsOfNames)(REFIID riid, OLECHAR FAR* FAR* rgszNames, unsigned int cNames, LCID lcid, DISPID FAR* rgdispid);
  91. STDMETHOD (GetTypeInfo)(unsigned int itinfo, LCID lcid, ITypeInfo FAR* FAR* pptinfo);
  92. STDMETHOD (GetTypeInfoCount)(unsigned int FAR * pctinfo);
  93. STDMETHOD (Invoke)(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR *pdispparams, VARIANT FAR *pvarResult, EXCEPINFO FAR * pexecinfo, unsigned int FAR *puArgErr);
  94. // *** IDocHostUIHandler Methods ***
  95. STDMETHOD (ShowContextMenu)(DWORD dwID, POINT __RPC_FAR *ppt, IUnknown __RPC_FAR *pcmdtReserved, IDispatch __RPC_FAR *pdispReserved);
  96. STDMETHOD (GetHostInfo)(DOCHOSTUIINFO __RPC_FAR *pInfo);
  97. STDMETHOD (ShowUI)(DWORD dwID, IOleInPlaceActiveObject __RPC_FAR *pActiveObject, IOleCommandTarget __RPC_FAR *pCommandTarget, IOleInPlaceFrame __RPC_FAR *pFrame, IOleInPlaceUIWindow __RPC_FAR *pDoc);
  98. STDMETHOD (HideUI)(void);
  99. STDMETHOD (UpdateUI)(void);
  100. STDMETHOD (OnDocWindowActivate)(BOOL fActivate);
  101. STDMETHOD (OnFrameWindowActivate)(BOOL fActivate);
  102. STDMETHOD (ResizeBorder)(LPCRECT prcBorder, IOleInPlaceUIWindow __RPC_FAR *pUIWindow, BOOL fRameWindow);
  103. STDMETHOD (TranslateAccelerator)(LPMSG lpMsg, const GUID __RPC_FAR *pguidCmdGroup, DWORD nCmdID);
  104. STDMETHOD (GetOptionKeyPath)(LPOLESTR __RPC_FAR *pchKey, DWORD dw);
  105. STDMETHOD (GetDropTarget)(IDropTarget __RPC_FAR *pDropTarget, IDropTarget __RPC_FAR *__RPC_FAR *ppDropTarget);
  106. STDMETHOD (GetExternal)(IDispatch __RPC_FAR *__RPC_FAR *ppDispatch);
  107. STDMETHOD (TranslateUrl)(DWORD dwTranslate, OLECHAR __RPC_FAR *pchURLIn, OLECHAR __RPC_FAR *__RPC_FAR *ppchURLOut);
  108. STDMETHOD (FilterDataObject)(IDataObject __RPC_FAR *pDO, IDataObject __RPC_FAR *__RPC_FAR *ppDORet);
  109. // STDMETHOD (EnableModeless)(BOOL fEnable);
  110. public:
  111. void add(CLSID clsid);
  112. void remove();
  113. void setLocation(int x, int y, int width, int height);
  114. void setVisible(BOOL fVisible);
  115. void setFocus(BOOL fFocus);
  116. void setStatusWindow(HWND hwndStatus);
  117. bool translateKey(LPMSG pMsg);
  118. virtual void OnBeforeNavigate(void) {} // deprecated
  119. virtual void OnNavigateError(void) {} // deprecated
  120. virtual void OnNavigateComplete(void) {} // deprecated
  121. virtual void OnBeforeNavigate(IDispatch *pDispatch, LPCWSTR pszURL, DWORD dwFlags, LPCWSTR pszTargetFrameName, VARIANT *vtPostData, LPCWSTR pszHeaders, VARIANT_BOOL *Cancel);
  122. virtual void OnNavigateError(IDispatch *pDispatch, LPCWSTR pszURL, LPCWSTR pszTargetFrameName, INT nStatusCode, VARIANT_BOOL *Cancel);
  123. virtual void OnNavigateComplete(IDispatch *pDispatch, LPCWSTR pszURL);
  124. virtual void OnDocumentComplete(IDispatch *pDisp, LPCWSTR pszURL);
  125. virtual void OnDownloadBegin(void);
  126. virtual void OnDownloadComplete(void);
  127. virtual void OnFileDownload(VARIANT_BOOL *ActiveDocument, VARIANT_BOOL *Cancel);
  128. virtual void OnNewWindow2(IDispatch **ppDisp, VARIANT_BOOL *Cancel);
  129. virtual void OnNewWindow3(IDispatch **ppDisp, VARIANT_BOOL *Cancel, DWORD dwFlags, LPCWSTR pszUrlContext, LPCWSTR pszUrl);
  130. virtual void OnProgressChange(long Progress, long ProgressMax);
  131. virtual void OnStatusTextChange(LPCWSTR pszText);
  132. void close();
  133. virtual BOOL SetHostCSS(LPCWSTR pszHostCSS);
  134. virtual HWND GetHostHWND(void);
  135. DWORD SetDownloadFlags(DWORD dwFlags);
  136. DWORD SetHostInfoFlags(DWORD dwFlags);
  137. IDispatch *getDispatch();
  138. IUnknown * getUnknown();
  139. IWebBrowser2 *m_pweb;
  140. void SyncSizeToWindow(HWND window);
  141. IConnectionPoint *GetConnectionPoint(REFIID riid);
  142. DWORD m_dwCookie;
  143. private:
  144. wchar_t *pszHostCSS;
  145. DWORD dwDownloadFlags;
  146. DWORD dwHostInfoFlags;
  147. };
  148. #endif