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.

278 lines
12 KiB

  1. // Copyright (C) 1996-1997 Microsoft Corporation. All rights reserved.
  2. #ifndef FASTCALL
  3. #define FASTCALL __fastcall
  4. #endif
  5. #define SETTHIS(hwnd) SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
  6. #define GETTHIS(Class,hwnd) (reinterpret_cast<Class*>(GetWindowLongPtr(hwnd, GWLP_USERDATA)))
  7. #define DESTROYIFVALID(hwnd) if (IsValidWindow(hwnd)) DestroyWindow(hwnd);
  8. #define STR_BSTR 0
  9. #define STR_OLESTR 1
  10. #define BSTRFROMANSI(x) (BSTR)MakeWideStrFromAnsi((LPSTR)(x), STR_BSTR)
  11. #define OLESTRFROMANSI(x) (LPOLESTR)MakeWideStrFromAnsi((LPSTR)(x), STR_OLESTR)
  12. #define BSTRFROMRESID(x) (BSTR)MakeWideStrFromResourceId(x, STR_BSTR)
  13. #define OLESTRFROMRESID(x) (LPOLESTR)MakeWideStrFromResourceId(x, STR_OLESTR)
  14. #define COPYOLESTR(x) (LPOLESTR)MakeWideStrFromWide(x, STR_OLESTR)
  15. #define COPYBSTR(x) (BSTR)MakeWideStrFromWide(x, STR_BSTR)
  16. #define UnregisterControlObject UnregisterAutomationObject
  17. #define ELEMENTS(array) (sizeof(array) / sizeof(array[0]))
  18. #define HH_URL_PREFIX_LESS 1
  19. #define HH_URL_UNQUALIFIED 2
  20. #define HH_URL_QUALIFIED 3
  21. #define HH_URL_JAVASCRIPT ((UINT)-2)
  22. #define HH_URL_UNKNOWN ((UINT)-1)
  23. // *********************** Assertion Definitions ************************** //
  24. // Get rid of any previously defined versions
  25. #undef ASSERT
  26. #undef VERIFY
  27. #ifndef THIS_FILE
  28. #define THIS_FILE __FILE__
  29. #endif
  30. // *********************** Function Prototypes **************************** //
  31. #if defined(_DEBUG)
  32. void AssertErrorReport(PCSTR pszExpression, UINT line, LPCSTR pszFile);
  33. #endif
  34. class CStr; // forward reference
  35. // functions formerly in hhctrlex.h
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif // __cplusplus
  39. //PSTR stristr(PCSTR pszMain, PCSTR pszSub); // case-insensitive string search
  40. PSTR FirstNonSpace(PCSTR psz); // return pointer to first non-space character
  41. WCHAR *FirstNonSpaceW(WCHAR *psz); // return pointer to first non-space character
  42. //PSTR StrChr(PCSTR pszString, char ch); // DBCS-aware character search
  43. PSTR StrRChr(PCSTR pszString, char ch); // DBCS-aware character search
  44. DWORD WinHelpHashFromSz(PCSTR pszKey); // converts string into a WinHelp-compatible hash number
  45. #ifdef __cplusplus
  46. }
  47. #endif // __cplusplus
  48. BOOL __cdecl _FormatMessage(LPCSTR szTemplate, LPSTR szBuf, UINT cchBuf, ...);
  49. LRESULT WINAPI HelpWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  50. LRESULT WINAPI ChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
  51. DWORD CreatePath(PSTR pszPath);
  52. void AddTrailingBackslash(PSTR psz);
  53. LPSTR CatPath(LPSTR lpTop, LPCSTR lpTail);
  54. HWND ChangeHtmlTopic(PCSTR pszFile, HWND hwndChild, BOOL bHighlight = FALSE);
  55. BOOL CheckForLicense();
  56. BOOL CheckLicenseKey(LPWSTR wszCheckme);
  57. void CheckWindowPosition(RECT* prc, BOOL fAllowShrinkage);
  58. void ConvertBackSlashToForwardSlash(PSTR pszUrl);
  59. void ConvertSpacesToEscapes(PCSTR pszSrc, CStr* pcszDst);
  60. BOOL ConvertToCacheFile(PCSTR pszSrc, PSTR pszDst);
  61. int ConvertWz(const WCHAR * pwz, char * psz, int len);
  62. HPALETTE CreateBIPalette(PBITMAPINFOHEADER pbihd);
  63. HRESULT CreateComponentCategory(GUID catid, WCHAR* catDescription);
  64. void CreateDefaultWindowType(PCSTR pszCompiledFile, PCSTR pszWindow);
  65. BOOL CreateFolder(PCSTR pszPath);
  66. int IEColorToWin32Color( PCWSTR pwsz );
  67. HFONT CreateUserFont(PCSTR pszFont, COLORREF* pclrFont = NULL, HDC hDC = NULL, INT charset = -1);
  68. HFONT CreateUserFontW(WCHAR *pszFont, COLORREF* pclrFont = NULL, HDC hDC = NULL, INT charset = -1);
  69. void DeleteAllHmData();
  70. BOOL DeleteKeyAndSubKeys(HKEY hk, LPSTR pszSubKey);
  71. BOOL DlgOpenFile(HWND hwndParent, PCSTR pszFile, CStr* pcsz);
  72. BOOL DlgOpenDirectory(HWND hwndParent, CStr* pcsz);
  73. void doAuthorMsg(UINT idStringFormatResource, PCSTR pszSubString);
  74. HWND doDisplayIndex(HWND hwndCaller, LPCSTR pszFile, LPCTSTR pszKeyword);
  75. HWND doDisplayToc(HWND hwndCaller, LPCSTR pszFile, DWORD_PTR dwData);
  76. void doHhctrlVersion(HWND hwndParent, PCSTR pszCHMVersion);
  77. void doHHWindowJump(PCSTR pszUrl, HWND hwndChild);
  78. BOOL doJumpUrl(HWND hwndParent, PCSTR pszCurUrl, PSTR pszDstUrl);
  79. void doRelatedTopics(HWND);
  80. HWND doTpHelpWmHelp(HWND hwndMain, LPCSTR pszFile, DWORD_PTR ulData);
  81. HWND doTpHelpContextMenu(HWND hwndMain, LPCSTR pszFile, DWORD_PTR ulData);
  82. BOOL FindDarwinURL(PCSTR pszGUID, PCSTR pszChmFile, CStr* pcszResult);
  83. PCSTR FindEqCharacter(PCSTR pszLine);
  84. PCSTR FindFilePortion(PCSTR pszFile);
  85. HWND FindMessageParent(HWND hwndChild);
  86. BOOL FindThisFile(HWND hwndParent, PCSTR pszFile, CStr* pcszFile, BOOL fAskUser = TRUE);
  87. HWND FindTopLevelWindow(HWND hwnd);
  88. DWORD GetButtonDimensions(HWND hwnd, HFONT hFont, PCSTR psz);
  89. PCSTR GetCompiledName(PCSTR pszName, CStr* pcsz);
  90. BOOL GetHighContrastFlag(void);
  91. PSTR GetLeftOfEquals(PCSTR pszString);
  92. BSTR GetLicenseKey(void);
  93. HWND GetParentSize(RECT* prcParent, HWND hwndParent, int padding, int navpos);
  94. HWND GetParkingWindow(void);
  95. void GetRegWindowsDirectory(PSTR pszDstPath);
  96. void GetScreenResolution(HWND hWnd, RECT* prc);
  97. void GetWorkArea() ;
  98. DWORD GetStaticDimensions(HWND hwnd, HFONT hFont, PCSTR psz, int max_len );
  99. DWORD GetStaticDimensionsW(HWND hwnd, HFONT hFont, WCHAR *psz, int max_len );
  100. PCSTR GetStringResource(int idString);
  101. PCSTR GetStringResource(int idString, HINSTANCE);
  102. PCWSTR GetStringResourceW(int idString);
  103. PCWSTR GetStringResourceW(int idString, HINSTANCE);
  104. HASH HashFromSz(PCSTR pszKey);
  105. int HHA_Msg(UINT command, WPARAM wParam = 0, LPARAM lParam = 0);
  106. void HiMetricToPixel(const SIZEL *pSizeInHiMetric, SIZEL *pSizeinPixels);
  107. HWND xHtmlHelpA(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData);
  108. HWND xHtmlHelpW(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD_PTR dwData);
  109. BOOL IsCollectionFile(PCSTR pszFile);
  110. BOOL IsCompiledURL( PCSTR pszFile );
  111. UINT GetURLType( PCSTR pszURL );
  112. BOOL IsCompiledHtmlFile(PCSTR pszFile, CStr* pcszFile = NULL);
  113. BOOL IsHelpAuthor(HWND hwndCaller);
  114. BOOL IsSamePrefix(PCWSTR pwszMain, PCWSTR pwszSub, int cchPrefix = -1);
  115. BOOL IsSamePrefix(PCSTR pszMain, PCSTR pszSub, int cbPrefix = -1);
  116. BOOL IsThisAWinHelpFile(HWND hwndCaller, PCSTR pszFile);
  117. BOOL IsValidAddress(const void* lp, UINT nBytes, BOOL bReadWrite = TRUE);
  118. BOOL IsValidString(LPCSTR lpsz, int nLength = -1);
  119. BOOL IsValidString(LPCWSTR lpsz, int nLength = -1);
  120. void ItDoesntWork(void);
  121. LPWSTR MakeWideStr(LPSTR psz, UINT codepage);
  122. LPWSTR MakeWideStrFromAnsi(LPSTR, BYTE bType);
  123. LPWSTR MakeWideStrFromResourceId(WORD, BYTE bType);
  124. LPWSTR MakeWideStrFromWide(LPWSTR, BYTE bType);
  125. void MemMove(void * dst, const void * src, int count);
  126. BOOL MoveClientWindow(HWND hwndParent, HWND hwndChild, const RECT *prc, BOOL fRedraw);
  127. int MsgBox(int idFormatString, PCSTR pszSubString, UINT nType = MB_OK);
  128. int MsgBox(int idString, UINT nType = MB_OK);
  129. int MsgBox(PCSTR pszMsg, UINT nType = MB_OK);
  130. LPVOID OleAlloc(UINT cb);
  131. void OleFree(LPVOID pb);
  132. HRESULT OleInitMalloc(void);
  133. HWND OnDisplayPopup(HWND hwndCaller, LPCSTR pszFile, DWORD dwData);
  134. HWND OnDisplayTopic(HWND hwndCaller, LPCSTR pszFile, DWORD_PTR dwData);
  135. HWND OnHelpContext(HWND hwndCaller, LPCSTR pszFile, DWORD_PTR dwData);
  136. void OOM(void);
  137. BOOL PaintShadowBackground(HWND hwnd, HDC hdc, COLORREF clrBackground = (COLORREF) -1);
  138. void PixelToHiMetric(const SIZEL *pSizeInPixels, SIZEL *pSizeInHiMetric);
  139. void QSort(void *pbase, UINT num, UINT width, int (FASTCALL *compare)(const void *, const void *));
  140. BOOL RegisterAutomationObject(LPCSTR pszLibName, LPCSTR pszObjectName, long lVersion, REFCLSID riidLibrary, REFCLSID riidObject);
  141. HRESULT RegisterCLSIDInCategory(REFCLSID clsid, GUID catid);
  142. BOOL RegisterControlObject(LPCSTR pszLibName, LPCSTR pszObjectName, long lVersion, REFCLSID riidLibrary, REFCLSID riidObject, DWORD dwMiscStatus, WORD wToolboxBitmapId);
  143. void RegisterOurWindow();
  144. BOOL RegisterUnknownObject(LPCSTR pszObjectName, REFCLSID riidObject);
  145. BOOL RegSetMultipleValues(HKEY hkey, ...);
  146. void RemoveTrailingSpaces(PSTR pszString);
  147. void SendStringToParent(PCSTR pszMsg);
  148. PSTR StrToken(PSTR pszList, PCSTR pszDelimeters);
  149. PSTR SzTrimSz(PSTR pszOrg);
  150. BOOL UnregisterAutomationObject(LPCSTR pszLibName, LPCSTR pszObjectName, long lVersion, REFCLSID riidObject);
  151. HRESULT UnRegisterCLSIDInCategory(REFCLSID clsid, GUID catid);
  152. BOOL UnregisterData(void);
  153. BOOL UnregisterTypeLibrary(REFCLSID riidLibrary);
  154. BOOL UnregisterUnknownObject(REFCLSID riidObject);
  155. typedef UINT (WINAPI *PFN_GETWINDOWSDIRECTORY)( LPTSTR lpBuffer, UINT uSize );
  156. typedef enum { HH_SYSTEM_WINDOWS_DIRECTORY, HH_USERS_WINDOWS_DIRECTORY } SYSDIRTYPES;
  157. UINT HHGetWindowsDirectory( LPSTR lpBuffer, UINT uSize, UINT uiType = HH_SYSTEM_WINDOWS_DIRECTORY );
  158. UINT HHGetHelpDirectory( LPSTR lpBuffer, UINT uSize );
  159. UINT HHGetGlobalCollectionPathname( LPTSTR lpBuffer, UINT uSize , BOOL *pbNewPath);
  160. UINT HHGetOldGlobalCollectionPathname( LPTSTR lpBuffer, UINT uSize );
  161. HRESULT HHGetUserDataPath( LPSTR pszPath );
  162. HRESULT HHGetHelpDataPath( LPSTR pszPath );
  163. HRESULT HHGetUserDataPathname( LPSTR lpBuffer, UINT uSize );
  164. HRESULT HHGetCurUserDataPath( LPSTR pszPath );
  165. // Internal API definitions.
  166. #include "hhpriv.h"
  167. // Look for the information in the hhcolreg.dat file.
  168. int GetLocationFromTitleTag(LPCSTR szCollection, HH_TITLE_FULLPATH* pTitleFullPath) ;
  169. int FASTCALL CompareIntPointers(const void *pval1, const void *pval2);
  170. void FASTCALL Itoa(int val, PSTR pszDst);
  171. int FASTCALL Atoi(PCSTR psz);
  172. // *********************** Debug/Internal Functions ********************** //
  173. #ifdef _DEBUG
  174. // IASSERT is available in _DEBUG builds
  175. #define IASSERT(exp) \
  176. { \
  177. ((exp) ? (void) 0 : \
  178. AssertErrorReport(#exp, __LINE__, THIS_FILE)); \
  179. }
  180. #define IASSERT_COMMENT(exp, pszComment) \
  181. { \
  182. ((exp) ? (void) 0 : \
  183. AssertErrorReport(pszComment, __LINE__, THIS_FILE)); \
  184. }
  185. #else
  186. #define IASSERT(exp)
  187. #define IASSERT_COMMENT(exp, pszComment)
  188. #endif
  189. #ifdef _DEBUG
  190. #define ASSERT(exp) \
  191. { \
  192. ((exp) ? (void) 0 : \
  193. AssertErrorReport(#exp, __LINE__, THIS_FILE)); \
  194. }
  195. #define ASSERT_COMMENT(exp, pszComment) \
  196. { \
  197. ((exp) ? (void) 0 : \
  198. AssertErrorReport(pszComment, __LINE__, THIS_FILE)); \
  199. }
  200. #define FAIL(pszComment) AssertErrorReport(pszComment, __LINE__, THIS_FILE);
  201. #define VERIFY(exp) ASSERT(exp)
  202. #define VERIFY_RESULT(exp1, exp2) ASSERT((exp1) == (exp2))
  203. #define DEBUG_ReportOleError doReportOleError
  204. void doReportOleError(HRESULT hres);
  205. __inline void DBWIN(PCSTR psz) {
  206. SendStringToParent(psz);
  207. SendStringToParent("\r\n");
  208. }
  209. #define CHECK_POINTER(val) if (!(val) || IsBadWritePtr((void *)(val), sizeof(void *))) return E_POINTER
  210. #else // non-debugging version
  211. #define ASSERT(exp)
  212. #define ASSERT_COMMENT(exp, pszComment)
  213. #define VERIFY(exp) ((void)(exp))
  214. #define VERIFY_RESULT(exp1, exp2) ((void)(exp))
  215. #define DEBUG_ReportOleError(hres)
  216. #define DBWIN(psz)
  217. #define FAIL(pszComment)
  218. #define CHECK_POINTER(val)
  219. #define THIS_FILE __FILE__
  220. #endif
  221. // zero fill everything after the vtbl pointer
  222. #define ZERO_INIT_CLASS(base_class) \
  223. ClearMemory((PBYTE) ((base_class*) this) + sizeof(base_class*), \
  224. sizeof(*this) - sizeof(base_class*));
  225. #define ZERO_STRUCTURE(foo) ClearMemory(&foo, sizeof(foo))
  226. #define ClearMemory(p, cb) memset(p, 0, cb)
  227. __inline void StrCopyWide(LPWSTR psz1, LPCWSTR psz2) {
  228. while (*psz1++ = *psz2++);
  229. }
  230. // HHA functions
  231. extern int (STDCALL *pDllMsgBox)(int idFormatString, PCSTR pszSubString, UINT nType);
  232. extern PCSTR (STDCALL *pGetDllStringResource)(int idFormatString);
  233. void WINAPI AWMessagePump(HWND hwnd);