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.

391 lines
8.3 KiB

  1. /*++ BUILD Version: 0002 // Increment this if a change has global effects
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. Wintools.h
  5. Abstract:
  6. This is the master headerfile for the Wintools library.
  7. Author:
  8. David J. Gilman (davegi) 28-Oct-1992
  9. Gregg R. Acheson (GreggA) 28-Feb-1994
  10. Environment:
  11. User Mode
  12. --*/
  13. #if ! defined( _WINTOOLS_ )
  14. #define _WINTOOLS_
  15. #include <windows.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. //
  20. //*** Global types.
  21. //
  22. #if defined( UNICODE )
  23. typedef WCHAR* LPTCHAR;
  24. #else // ! UNICODE
  25. typedef char* LPTCHAR;
  26. #endif // UNICODE
  27. //
  28. //*** Debug Information Support.
  29. //
  30. extern
  31. struct
  32. DEBUG_FLAGS
  33. WintoolsGlobalFlags;
  34. #if DBG
  35. VOID
  36. DebugAssertW(
  37. IN LPCWSTR Expression,
  38. IN LPCSTR File,
  39. IN DWORD LineNumber
  40. );
  41. VOID
  42. DebugPrintfW(
  43. IN LPCWSTR Format,
  44. IN ...
  45. );
  46. #define DbgAssert( exp ) \
  47. (( exp ) \
  48. ? ( VOID ) 0 \
  49. : ( VOID ) DebugAssertW( \
  50. TEXT( #exp ), \
  51. __FILE__, \
  52. __LINE__ \
  53. ));
  54. #define DbgHandleAssert( h ) \
  55. DbgAssert((( h ) != NULL ) && (( h ) != INVALID_HANDLE_VALUE ))
  56. #define DbgPointerAssert( p ) \
  57. DbgAssert(( p ) != NULL )
  58. #define DbgPrintf( _x_ ) \
  59. DebugPrintfW _x_
  60. #else // ! DBG
  61. #define DbgAssert( exp )
  62. #define DbgHandleAssert( h )
  63. #define DbgPointerAssert( p )
  64. #define DbgPrintf( _x_ )
  65. #endif // DBG
  66. //
  67. //*** Object Signature Support.
  68. //
  69. #if SIGNATURE
  70. #define DECLARE_SIGNATURE \
  71. DWORD_PTR Signature;
  72. #define SetSignature( p ) \
  73. (( p )->Signature = ( DWORD_PTR ) &(( p )->Signature ))
  74. #define CheckSignature( p ) \
  75. (( p )->Signature == ( DWORD_PTR ) &(( p )->Signature ))
  76. #else // ! SIGNATURE
  77. #define DECLARE_SIGNATURE
  78. #define SetSignature( p )
  79. #define CheckSignature( p )
  80. #endif // SIGNATURE
  81. //
  82. //*** 3d Controls Support.
  83. //
  84. #if defined( CTL3D )
  85. #include "ctl3d.h"
  86. //
  87. // Handle all of the WM_CTLCOLOR messages for a dlgproc.
  88. //
  89. #define CASE_WM_CTLCOLOR_DIALOG \
  90. case WM_CTLCOLORMSGBOX: \
  91. case WM_CTLCOLOREDIT: \
  92. case WM_CTLCOLORLISTBOX: \
  93. case WM_CTLCOLORBTN: \
  94. case WM_CTLCOLORDLG: \
  95. case WM_CTLCOLORSCROLLBAR: \
  96. case WM_CTLCOLORSTATIC: \
  97. return ( BOOL ) Ctl3dCtlColorEx( message, wParam, lParam )
  98. //
  99. // Handle all of the WM_CTLCOLOR messages for a wndproc.
  100. //
  101. #define CASE_WM_CTLCOLOR_WINDOW \
  102. case WM_CTLCOLORMSGBOX: \
  103. case WM_CTLCOLOREDIT: \
  104. case WM_CTLCOLORLISTBOX: \
  105. case WM_CTLCOLORBTN: \
  106. case WM_CTLCOLORDLG: \
  107. case WM_CTLCOLORSCROLLBAR: \
  108. case WM_CTLCOLORSTATIC: \
  109. { \
  110. HBRUSH hBrush; \
  111. hBrush = Ctl3dCtlColorEx( message, wParam, lParam ); \
  112. if( hBrush != NULL ) { \
  113. return ( LRESULT ) hBrush; \
  114. } else { \
  115. break; \
  116. } \
  117. }
  118. #else // ! CTL3D
  119. #define CASE_WM_CTLCOLOR_DIALOG \
  120. ( VOID ) 0;
  121. #define CASE_WM_CTLCOLOR_WINDOW \
  122. ( VOID ) 0;
  123. #endif // CTL3D
  124. //
  125. //*** Miscellaneous Macros.
  126. //
  127. #define ARGUMENT_PRESENT(ArgumentPointer) (\
  128. (CHAR *)(ArgumentPointer) != (CHAR *)(NULL) )
  129. #define IsSwitch( x ) \
  130. ((( x ) == TEXT( '-' )) || (( x ) == TEXT( '/' )))
  131. #define NumberOfCharacters( x ) \
  132. ( sizeof(( x )) / sizeof( TCHAR ))
  133. #define NumberOfEntries( x ) \
  134. ( sizeof(( x )) / sizeof(( x )[ 0 ]))
  135. //
  136. //*** Global constants.
  137. //
  138. //
  139. // Maximum number of charaters in a string.
  140. //
  141. #define MAX_CHARS ( 2048 )
  142. //
  143. //*** Memory Management Support
  144. //
  145. #define AllocateMemory( t, s ) \
  146. (( LP##t ) LocalAlloc( LPTR, ( s )))
  147. #define AllocateObject( t, c ) \
  148. ( AllocateMemory( t, sizeof( t ) * ( c )))
  149. #define ReallocateMemory( t, p, s ) \
  150. (( LP##t ) LocalReAlloc(( HLOCAL )( p ), ( s ), LMEM_MOVEABLE ))
  151. #define ReallocateObject( t, p, c ) \
  152. ( ReallocateMemory( t, ( p ), sizeof( t ) * ( c )))
  153. #define FreeMemory( p ) \
  154. ((( p ) == NULL ) \
  155. ? TRUE \
  156. : (((p)=( LPVOID ) LocalFree(( HLOCAL )( p ))) == NULL ))
  157. #define FreeObject( p ) \
  158. FreeMemory(( p ))
  159. //
  160. //*** String table support.
  161. //
  162. typedef
  163. struct
  164. _STRING_TABLE_ENTRY {
  165. ULARGE_INTEGER Key;
  166. UINT Id;
  167. } STRING_TABLE_ENTRY, *LPSTRING_TABLE_ENTRY;
  168. #define MAKE_TABLE_ENTRY( c, v ) { v, c, IDS_##v }
  169. //
  170. //*** Miscellaneous types.
  171. //
  172. typedef
  173. struct
  174. _VALUE_ID_MAP {
  175. int Value;
  176. int Id;
  177. } VALUE_ID_MAP, *LPVALUE_ID_MAP;
  178. //
  179. //*** Function Prototypes.
  180. //
  181. LPCTSTR%
  182. BaseName%(
  183. IN LPCTSTR% Name
  184. );
  185. INT
  186. Stricmp%(
  187. IN LPCTSTR% String1,
  188. IN LPCTSTR% String2
  189. );
  190. int
  191. ConsolePrintf%(
  192. IN UINT Format,
  193. IN ...
  194. );
  195. DWORD
  196. DialogPrintf(
  197. IN HWND hWnd,
  198. IN int ControlId,
  199. IN UINT FormatId,
  200. IN ...
  201. );
  202. VOID
  203. ErrorExit%(
  204. IN UINT ExitCode,
  205. IN UINT Format,
  206. IN ...
  207. );
  208. BOOL
  209. EnableControl(
  210. IN HWND hWnd,
  211. IN int ControlId,
  212. IN BOOL Enable
  213. );
  214. BOOL
  215. GetCharMetrics%(
  216. IN HDC hDC,
  217. IN LPLONG CharWidth,
  218. IN LPLONG CharHeight
  219. );
  220. BOOL
  221. GetClientSize(
  222. IN HWND hWnd,
  223. IN LPLONG ClientWidth,
  224. IN LPLONG ClientHeight
  225. );
  226. LPCTSTR%
  227. GetString%(
  228. IN UINT StringId
  229. );
  230. UINT
  231. GetStringId(
  232. IN LPSTRING_TABLE_ENTRY StringTable,
  233. IN DWORD Count,
  234. IN int Class,
  235. IN DWORD Value
  236. );
  237. BOOL
  238. IsDlgItemUnicode(
  239. IN HWND hWnd,
  240. IN int ControlId
  241. );
  242. BOOL
  243. SetDlgItemBigInt(
  244. IN HWND hWnd,
  245. IN int ControlId,
  246. IN UINT Value,
  247. IN BOOL Signed
  248. );
  249. BOOL
  250. SetDlgItemHex(
  251. IN HWND hWnd,
  252. IN int ControlId,
  253. IN UINT Value
  254. );
  255. BOOL
  256. SetScrollPosEx(
  257. IN HWND hWnd,
  258. IN INT fnBar,
  259. IN INT nPos,
  260. IN BOOL fRedraw,
  261. OUT PINT pnOldPos
  262. );
  263. BOOL
  264. SetFixedPitchFont(
  265. IN HWND hWnd,
  266. IN int ControlId
  267. );
  268. LPTSTR%
  269. FormatLargeInteger%(
  270. IN PLARGE_INTEGER LargeInteger,
  271. IN BOOL Signed
  272. );
  273. LPTSTR%
  274. FormatBigInteger%(
  275. IN DWORD BigInteger,
  276. IN BOOL Signed
  277. );
  278. DWORD
  279. WFormatMessage%(
  280. IN LPTSTR% Buffer,
  281. IN DWORD BufferSize,
  282. IN UINT FormatId,
  283. IN ...
  284. );
  285. #ifdef __cplusplus
  286. } // extern C
  287. #endif
  288. #endif // _WINTOOLS_