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.

272 lines
11 KiB

  1. // Copyright (C) 1996-1997 Microsoft Corporation. All rights reserved.
  2. #ifndef FASTCALL
  3. #define FASTCALL __fastcall
  4. #endif
  5. #define SETTHIS(hwnd) SetWindowLong(hwnd, GWL_USERDATA, reinterpret_cast<LONG>(this));
  6. #define GETTHIS(Class,hwnd) (reinterpret_cast<Class*>(GetWindowLong(hwnd, GWL_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 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 ulData);
  81. HWND doTpHelpContextMenu(HWND hwndMain, LPCSTR pszFile, DWORD 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 dwData);
  108. HWND xHtmlHelpW(HWND hwndCaller, LPCWSTR pszFile, UINT uCommand, DWORD 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. LPVOID OleAlloc(UINT cb);
  128. void OleFree(LPVOID pb);
  129. HRESULT OleInitMalloc(void);
  130. HWND OnDisplayPopup(HWND hwndCaller, LPCSTR pszFile, DWORD dwData);
  131. HWND OnDisplayTopic(HWND hwndCaller, LPCSTR pszFile, DWORD dwData);
  132. HWND OnHelpContext(HWND hwndCaller, LPCSTR pszFile, DWORD dwData);
  133. void OOM(void);
  134. BOOL PaintShadowBackground(HWND hwnd, HDC hdc, COLORREF clrBackground = (COLORREF) -1);
  135. void PixelToHiMetric(const SIZEL *pSizeInPixels, SIZEL *pSizeInHiMetric);
  136. void QSort(void *pbase, UINT num, UINT width, int (FASTCALL *compare)(const void *, const void *));
  137. BOOL RegisterAutomationObject(LPCSTR pszLibName, LPCSTR pszObjectName, long lVersion, REFCLSID riidLibrary, REFCLSID riidObject);
  138. HRESULT RegisterCLSIDInCategory(REFCLSID clsid, GUID catid);
  139. BOOL RegisterControlObject(LPCSTR pszLibName, LPCSTR pszObjectName, long lVersion, REFCLSID riidLibrary, REFCLSID riidObject, DWORD dwMiscStatus, WORD wToolboxBitmapId);
  140. void RegisterOurWindow();
  141. BOOL RegisterUnknownObject(LPCSTR pszObjectName, REFCLSID riidObject);
  142. BOOL RegSetMultipleValues(HKEY hkey, ...);
  143. void RemoveTrailingSpaces(PSTR pszString);
  144. void SendStringToParent(PCSTR pszMsg);
  145. PSTR StrToken(PSTR pszList, PCSTR pszDelimeters);
  146. PSTR SzTrimSz(PSTR pszOrg);
  147. BOOL UnregisterAutomationObject(LPCSTR pszLibName, LPCSTR pszObjectName, long lVersion, REFCLSID riidObject);
  148. HRESULT UnRegisterCLSIDInCategory(REFCLSID clsid, GUID catid);
  149. BOOL UnregisterData(void);
  150. BOOL UnregisterTypeLibrary(REFCLSID riidLibrary);
  151. BOOL UnregisterUnknownObject(REFCLSID riidObject);
  152. UINT HHGetHelpDirectory( LPSTR lpBuffer, UINT uSize );
  153. UINT HHGetGlobalCollectionPathname( LPTSTR lpBuffer, UINT uSize , BOOL *pbNewPath);
  154. UINT HHGetOldGlobalCollectionPathname( LPTSTR lpBuffer, UINT uSize );
  155. HRESULT HHGetUserDataPath( LPSTR pszPath );
  156. HRESULT HHGetUserDataPath( LPSTR pszPath );
  157. HRESULT HHGetHelpDataPath( LPSTR pszPath );
  158. HRESULT HHGetUserDataPathname( LPSTR lpBuffer, UINT uSize );
  159. HRESULT HHGetCurUserDataPath( LPSTR pszPath );
  160. // Internal API definitions.
  161. #include "hhpriv.h"
  162. // Look for the information in the hhcolreg.dat file.
  163. int GetLocationFromTitleTag(LPCSTR szCollection, HH_TITLE_FULLPATH* pTitleFullPath) ;
  164. int FASTCALL CompareIntPointers(const void *pval1, const void *pval2);
  165. void FASTCALL Itoa(int val, PSTR pszDst);
  166. int FASTCALL Atoi(PCSTR psz);
  167. // *********************** Debug/Internal Functions ********************** //
  168. #ifdef _DEBUG
  169. // IASSERT is available in _DEBUG builds
  170. #define IASSERT(exp) \
  171. { \
  172. ((exp) ? (void) 0 : \
  173. AssertErrorReport(#exp, __LINE__, THIS_FILE)); \
  174. }
  175. #define IASSERT_COMMENT(exp, pszComment) \
  176. { \
  177. ((exp) ? (void) 0 : \
  178. AssertErrorReport(pszComment, __LINE__, THIS_FILE)); \
  179. }
  180. #else
  181. #define IASSERT(exp)
  182. #define IASSERT_COMMENT(exp, pszComment)
  183. #endif
  184. #ifdef _DEBUG
  185. #define ASSERT(exp) \
  186. { \
  187. ((exp) ? (void) 0 : \
  188. AssertErrorReport(#exp, __LINE__, THIS_FILE)); \
  189. }
  190. #define ASSERT_COMMENT(exp, pszComment) \
  191. { \
  192. ((exp) ? (void) 0 : \
  193. AssertErrorReport(pszComment, __LINE__, THIS_FILE)); \
  194. }
  195. #define FAIL(pszComment) AssertErrorReport(pszComment, __LINE__, THIS_FILE);
  196. #define VERIFY(exp) ASSERT(exp)
  197. #define VERIFY_RESULT(exp1, exp2) ASSERT((exp1) == (exp2))
  198. #define DEBUG_ReportOleError doReportOleError
  199. void doReportOleError(HRESULT hres);
  200. __inline void DBWIN(PCSTR psz) {
  201. SendStringToParent(psz);
  202. SendStringToParent("\r\n");
  203. }
  204. #define CHECK_POINTER(val) if (!(val) || IsBadWritePtr((void *)(val), sizeof(void *))) return E_POINTER
  205. #else // non-debugging version
  206. #define ASSERT(exp)
  207. #define ASSERT_COMMENT(exp, pszComment)
  208. #define VERIFY(exp) ((void)(exp))
  209. #define VERIFY_RESULT(exp1, exp2) ((void)(exp))
  210. #define DEBUG_ReportOleError(hres)
  211. #define DBWIN(psz)
  212. #define FAIL(pszComment)
  213. #define CHECK_POINTER(val)
  214. #define THIS_FILE __FILE__
  215. #endif
  216. // zero fill everything after the vtbl pointer
  217. #define ZERO_INIT_CLASS(base_class) \
  218. ClearMemory((PBYTE) ((base_class*) this) + sizeof(base_class*), \
  219. sizeof(*this) - sizeof(base_class*));
  220. #define ZERO_STRUCTURE(foo) ClearMemory(&foo, sizeof(foo))
  221. #define ClearMemory(p, cb) memset(p, 0, cb)
  222. __inline void StrCopyWide(LPWSTR psz1, LPCWSTR psz2) {
  223. while (*psz1++ = *psz2++);
  224. }
  225. // HHA functions
  226. extern int (__stdcall *pDllMsgBox)(int idFormatString, PCSTR pszSubString, UINT nType);
  227. extern PCSTR (__stdcall *pGetDllStringResource)(int idFormatString);
  228. void WINAPI AWMessagePump(HWND hwnd);