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.

293 lines
10 KiB

  1. // Copyright 1995-1997 Microsoft Corporation. All Rights Reserved.
  2. #if _MSC_VER > 1000
  3. #pragma once
  4. #endif
  5. #ifndef _HHCTRL_H_
  6. #define _HHCTRL_H_
  7. #include "IPServer.H"
  8. #include "CtrlObj.H"
  9. #ifndef __IHHCtrl_FWD_DEFINED__
  10. #include "hhIfc.H"
  11. #endif
  12. #include "Dispids.H"
  13. #include "internet.h"
  14. #include <commctrl.h>
  15. #include "sitemap.h"
  16. #include "hhamsgs.h"
  17. #include "cindex.h"
  18. #include "ctoc.h"
  19. #include "prthook.h"
  20. #include <mshtml.h>
  21. typedef struct tagHHCtrlCTLSTATE
  22. {
  23. char *bmpPath;
  24. DATE endDate;
  25. } HHCTRLCTLSTATE;
  26. enum BMP_DOWNLOAD_STATES
  27. {
  28. bdsNoBitsYet,
  29. bdsGotFileHeader,
  30. bdsGotBitmapInfo,
  31. bdsGettingBits,
  32. bdsBitsAreDone
  33. };
  34. class CHtmlHelpControl; // forward reference
  35. class IWebBrowserAppImpl; // forward reference
  36. HWND JumpToUrl(IUnknown* pUnkOuter, HWND hwndParent, SITEMAP_ENTRY* pSiteMapEntry, CInfoType *pInfoType, CSiteMap* pSiteMap, SITE_ENTRY_URL* pUrl, IWebBrowserAppImpl* pWebApp = NULL);
  37. #if 0 //enable for subset filtering
  38. BOOL ChooseInformationTypes(CInfoType *pInfoType, CSiteMap* pSiteMap, HWND hwndParent, CHtmlHelpControl* phhctrl, CHHWinType* m_phh);
  39. #else
  40. BOOL ChooseInformationTypes(CInfoType *pInfoType, CSiteMap* pSiteMap, HWND hwndParent, CHtmlHelpControl* phhctrl);
  41. #endif
  42. void DisplayAuthorInfo(CInfoType *pInfoType, CSiteMap* pSiteMap, SITEMAP_ENTRY* pSiteMapEntry, HWND hwndParent, CHtmlHelpControl* phhctrl);
  43. HRESULT OnWordWheelLookup( PSTR pszKeywords, CExCollection* pExCollection,
  44. PCSTR pszDefaultTopic = NULL,
  45. POINT* ppt = NULL, HWND hWndParent = NULL,
  46. BOOL bDialog = TRUE, BOOL bKLink = TRUE,
  47. BOOL bTestMode = FALSE, BOOL bSkipCurrent = FALSE,
  48. BOOL bAlwaysShowList = FALSE,
  49. BOOL bAlphaSortHits = TRUE,
  50. PCSTR pszWindow = NULL);
  51. class CHtmlHelpControl : public CInternetControl, public IHHCtrl,
  52. public ISupportErrorInfo MI2_COUNT( CHtmlHelpControl )
  53. {
  54. public:
  55. // IUnknown methods
  56. DECLARE_STANDARD_UNKNOWN();
  57. // IDispatch methods
  58. DECLARE_STANDARD_DISPATCH();
  59. // ISupportErrorInfo methods
  60. DECLARE_STANDARD_SUPPORTERRORINFO();
  61. // IHHCtrl methods
  62. // OLE Control stuff follows:
  63. STDMETHOD(SetObjectRects)(LPCRECT lprcPosRect,LPCRECT lprcClipRect) ;
  64. CHtmlHelpControl(IUnknown *pUnkOuter);
  65. virtual ~CHtmlHelpControl();
  66. #ifndef PPGS
  67. STDMETHOD(DoVerb)(LONG iVerb, LPMSG lpmsg, IOleClientSite *pActiveSite, LONG lindex,
  68. HWND hwndParent, LPCRECT lprcPosRect);
  69. #endif
  70. STDMETHOD_(void, OnClick)(THIS);
  71. // static creation function. all controls must have one of these!
  72. static IUnknown *Create(IUnknown *);
  73. private:
  74. // overridables that the control must implement.
  75. STDMETHOD(LoadBinaryState)(IStream *pStream);
  76. STDMETHOD(SaveBinaryState)(IStream *pStream);
  77. STDMETHOD(LoadTextState)(IPropertyBag *pPropertyBag, IErrorLog *pErrorLog);
  78. STDMETHOD(SaveTextState)(IPropertyBag *pPropertyBag, BOOL fWriteDefault);
  79. STDMETHOD(OnDraw)(DWORD dvaspect, HDC hdcDraw, LPCRECTL prcBounds, LPCRECTL prcWBounds, HDC hicTargetDev, BOOL fOptimize);
  80. STDMETHOD(SetClientSite)(IOleClientSite *pClientSite);
  81. // Exposed methods
  82. STDMETHOD(Click)();
  83. STDMETHOD(HHClick)();
  84. STDMETHOD(Print)();
  85. STDMETHOD(syncURL)(BSTR pszUrl);
  86. STDMETHOD(TCard)(WPARAM wParam, LPARAM lParam);
  87. STDMETHOD(get_Image) (THIS_ BSTR* path);
  88. STDMETHOD(put_Image)(BSTR path);
  89. STDMETHOD(TextPopup)(BSTR pszText, BSTR pszFont, int horzMargins, int vertMargins, COLORREF clrForeground, COLORREF clrBackground);
  90. LRESULT WindowProc(UINT msg, WPARAM wParam, LPARAM lParam);
  91. void JumpToUrl(SITEMAP_ENTRY* pSiteMapEntry, CSiteMap* pSiteMap, SITE_ENTRY_URL* pUrl = NULL);
  92. void OnLButton(WPARAM wParam, LPARAM lParam);
  93. BOOL OnSetExtent(const SIZE *pSize);
  94. void ProcessPadding(PCSTR psz);
  95. BOOL RegisterClassData(void);
  96. void SetActionData(PCSTR psz);
  97. BOOL AfterCreateWindow(void);
  98. BOOL BeforeCreateWindow(DWORD *pdwWindowStyle, DWORD *pdwExWindowStyle, LPSTR pszWindowTitle);
  99. HRESULT InternalQueryInterface(REFIID, void **);
  100. HRESULT OnData( DISPID id, DWORD grfBSCF,IStream * bitstrm, DWORD amount );
  101. BOOL OnSpecialKey(LPMSG);
  102. BOOL ShouldCreateWindow();
  103. public:
  104. void doAboutBox();
  105. BOOL ConvertToCacheFile(PCSTR pszSrc, PSTR pszDst);
  106. void FillGeneralInformation(HHA_GEN_INFO* pgetInfo);
  107. // BOOL ChooseInformationTypes(CSiteMap* pSiteMap, HWND hwndParent) { return ::ChooseInformationTypes(pSiteMap, hwndParent, this); }
  108. void DisplayAuthorInfo(CSiteMap* pSiteMap, SITEMAP_ENTRY* pSiteMapEntry) { ::DisplayAuthorInfo(m_pInfoType, pSiteMap, pSiteMapEntry, m_hwnd, this); }
  109. void OnKeywordSearch(int idCommand);
  110. BOOL OnCopySample(void);
  111. BOOL LocateSFLFile(PCSTR *,PCSTR *, BOOL);
  112. void AuthorMsg(UINT idStringFormatResource, PCSTR pszSubString = "") { ::AuthorMsg(idStringFormatResource, pszSubString, m_hwndParent, this); }
  113. _inline IUnknown* GetIUnknown() { return m_pUnkOuter; }
  114. HRESULT SendEvent(LPCTSTR pszEventString);
  115. BOOL OnAKLink(BOOL fKLink = TRUE, BOOL bTestMode = FALSE );
  116. HWND GetHtmlHelpFrameWindow() ; // Tunnels from the ActiveX control through IE to get to the HWND of HHCTRL.
  117. UINT GetCodePage(void) { return m_CodePage; }
  118. INT GetCharset(void) { return m_Charset; }
  119. HFONT GetContentFont(void) { return m_hfont; }
  120. // TOC functions
  121. BOOL LoadContentsFile(PCSTR pszMasterFile);
  122. void OnHelpTopics(void);
  123. // Index functions
  124. BOOL LoadIndexFile(PCSTR pszMasterFile);
  125. void OnSizeIndex(LPRECT prc);
  126. HRESULT UpdateImage();
  127. // Related Topics functions
  128. void OnRelatedMenu();
  129. void OnRelatedCommand(int idCommand);
  130. // Splash functions
  131. void CreateSplash(void);
  132. // Button and Static text funcions
  133. void OnDrawStaticText(DRAWITEMSTRUCT* pdis);
  134. BOOL CreateOnClickButton(void);
  135. // private state information.
  136. HRESULT SetBmpPath(IStream *);
  137. CTRL_ACTION m_action;
  138. IMAGE_TYPE m_imgType;
  139. PCSTR m_pszActionData;
  140. int m_idBitmap; // bitmap to display
  141. PCSTR m_pszBitmap; // bitmap parameter
  142. PCSTR m_pszWebMap; // webmap file
  143. DWORD m_flags[MAX_FLAGS]; // author-specified flags
  144. HBRUSH m_hbrBackGround; // background brush
  145. COLORREF m_clrFont; // Font color
  146. BOOL m_fBuiltInImage;
  147. HGDIOBJ m_hImage;
  148. int m_hpadding; // horizontal padding around index, contents, and find
  149. int m_vpadding; // vertical padding around index, contents, and find
  150. HWND m_hwndHelp; // HTML Help window
  151. HWND m_hwndDisplayButton; // regular button handle
  152. PCSTR m_pszEventString; // string to send to event handler
  153. PCSTR m_pszFrame; // frame to display jump in
  154. PCSTR m_pszWindow; // window to display jump in
  155. PCSTR m_pszDefaultTopic; // where to jump if alink/klink fails
  156. class IWebBrowserAppImpl* m_pWebBrowserApp; // Pointer the IE object model
  157. CTable* m_ptblItems; // for A/KLinks
  158. CTable* m_ptblTitles; // for A/KLinks
  159. CTable* m_ptblURLs; // for A/KLinks
  160. CTable* m_ptblLocations; // for A/KLinks
  161. CSiteMap* m_pSiteMap; // used by Related Topics and Keyword Search
  162. CInfoType* m_pInfoType;
  163. IFont* m_pIFont;
  164. // REVIEW: using BOOLs increases data size, bitflags would increase
  165. // code size. Which is better (multiple data seg, single code seg)?
  166. BOOL m_fButton;
  167. BOOL m_fWinHelpPopup;
  168. BOOL m_fPopupMenu; // TRUE to display popup menu instead of dialog
  169. WCHAR* m_pwszButtonText; // bitmap or text
  170. RECT m_rcButton; // button window dimensions
  171. CToc* m_ptoc;
  172. CIndex* m_pindex;
  173. //CSearch* m_pSearch;
  174. BOOL m_fIcon; // bitmap is an icon or a cursor
  175. HHCTRLCTLSTATE m_state;
  176. HDC m_dc;
  177. BMP_DOWNLOAD_STATES m_readystate;
  178. DWORD m_oldSize;
  179. BYTE* m_pSelectedIndexInfoTypes;
  180. COLORREF m_clrFontDisabled; // disabled Font color (disabled)
  181. COLORREF m_clrFontLink; // Link Font color
  182. COLORREF m_clrFontLinkVisited; // Visited Link Font color
  183. COLORREF m_clrFontHover; // Hover Font color
  184. private:
  185. WNDPROC m_lpfnlStaticTextControlWndProc;
  186. static LRESULT StaticTextControlSubWndProc(HWND, UINT, WPARAM, LPARAM);
  187. char m_szRawAction[256];
  188. char m_szFontSpec[256];
  189. BOOL bSharedFont;
  190. UINT m_CodePage;
  191. INT m_Charset;
  192. HFONT m_hfont; // author-specified font to use for child windows
  193. RECT m_rect;
  194. };
  195. BOOL LoadGif(PCSTR pszFile, HBITMAP* phbmp, HPALETTE* phpal, CHtmlHelpControl* phhctrl);
  196. BOOL ShortCut(CHtmlHelpControl* phhctrl, LPCSTR pszString1, LPCSTR pszString2, HWND hwndMsgOwner);
  197. #ifdef CHIINDEX
  198. #define PrintTopics
  199. #else
  200. void PrintTopics(int action, CToc* ptoc, IWebBrowserAppImpl* pWebApp, HWND hWndHelp = NULL);
  201. #endif
  202. // TODO: if you have an array of verbs, then add an extern here with the name
  203. // of it, so that you can include it in the DEFINE_CONTROLOBJECT.
  204. // ie. extern VERBINFO m_HHCtrlCustomVerbs [];
  205. extern const GUID *rgHHCtrlPropPages[];
  206. DEFINE_CONTROLOBJECT(HHCtrl,
  207. &CLSID_HHCtrl,
  208. "HHCtrl",
  209. CHtmlHelpControl::Create,
  210. 1,
  211. &IID_IHHCtrl,
  212. "", // BUGBUG: change when OLE supports HtmlHelp files
  213. &DIID__HHCtrlEvents,
  214. OLEMISC_SETCLIENTSITEFIRST |
  215. OLEMISC_ACTIVATEWHENVISIBLE |
  216. OLEMISC_RECOMPOSEONRESIZE |
  217. OLEMISC_CANTLINKINSIDE |
  218. OLEMISC_INSIDEOUT,
  219. 0,
  220. RESID_TOOLBOX_BITMAP,
  221. "HHCtrlWndClass",
  222. 0,
  223. NULL,
  224. 0,
  225. NULL);
  226. #endif // _HHCTRL_H_