Leaked source code of windows server 2003
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.

397 lines
13 KiB

  1. /****************************************************************************
  2. *
  3. * Win32.h
  4. *
  5. * Windows 16/32 porting helper file
  6. *
  7. * Copyright (c) 1992 Microsoft Corporation. All Rights Reserved.
  8. *
  9. ***************************************************************************/
  10. #ifndef INC_OLE2
  11. #define INC_OLE2
  12. #endif
  13. #ifndef INC_WIN32_H
  14. #define INC_WIN32_H // Protect against double inclusion of this file
  15. #if !defined(WIN32) && defined(_WIN32)
  16. #define WIN32
  17. #endif
  18. #if !defined(DEBUG) && defined(_DEBUG)
  19. #define DEBUG
  20. #endif
  21. #ifdef WIN32
  22. // Set up a single define to allow CHICAGO or NT (Daytona)
  23. #ifdef UNICODE // Could use WINVER <= 0x400 ...
  24. #define DAYTONA
  25. #undef CHICAGO
  26. #else
  27. #ifndef CHICAGO
  28. #define CHICAGO
  29. #endif
  30. #undef DAYTONA
  31. #endif // UNICODE
  32. #ifndef RC_INVOKED
  33. #pragma warning(disable:4103)
  34. #endif
  35. #define _INC_OLE
  36. #else // 16 bit compilation - must be Chicago
  37. #ifndef CHICAGO
  38. #define CHICAGO
  39. #endif
  40. #endif // WIN32
  41. #if !defined(_INC_WINDOWS) || !defined(_WINDOWS)
  42. #include <windows.h>
  43. #include <windowsx.h>
  44. #if WINVER >= 0x400
  45. #include <winerror.h>
  46. #endif
  47. #include <mmsystem.h>
  48. #endif // INC_WINDOWS...
  49. #ifndef EXTERN_C
  50. #ifdef __cplusplus
  51. #define EXTERN_C extern "C"
  52. #else
  53. #define EXTERN_C extern
  54. #endif
  55. #endif
  56. // Not just for Daytona, things like mciavi define WINVER=0x30a
  57. #ifndef WS_EX_RIGHT
  58. #define WS_EX_RIGHT 0x00001000L // ;Internal 4.0
  59. #define WS_EX_LEFT 0x00000000L // ;Internal 4.0
  60. #define WS_EX_RTLREADING 0x00002000L // ;Internal 4.0
  61. #define WS_EX_LTRREADING 0x00000000L // ;Internal 4.0
  62. #define WS_EX_LEFTSCROLLBAR 0x00004000L // ;Internal 4.0
  63. #define WS_EX_RIGHTSCROLLBAR 0x00000000L // ;Internal 4.0
  64. #endif
  65. // Win 16 and Win 32 use different macros to turn code debugging on/off
  66. // Map the 16 bit version to the NT conventions.
  67. // In particular on NT, debug builds are identified by DBG==1 (and retail
  68. // with DBG==0), hence the NT only source uses #if DBG. Note: #ifdef DBG
  69. // is ALWAYS true on NT.
  70. // Chicago (and VFW 16 bit code) uses #ifdef DEBUG. The complex of
  71. // instructions below should ensure that whether this is Chicago or NT that
  72. // a debug build implies DEBUG defined and DBG==1
  73. // a retail build implies DEBUG NOT defined, and DBG==0
  74. #ifdef WIN32
  75. #ifndef DBG
  76. #ifdef DEBUG
  77. #define DBG 1
  78. #else
  79. #define DBG 0
  80. #endif
  81. #endif
  82. #undef DEBUG
  83. #if DBG
  84. #define DEBUG
  85. #define STATICFN
  86. #define STATICDT
  87. #else
  88. #define STATICFN static
  89. #define STATICDT static
  90. #endif
  91. #else // !WIN32
  92. #define STATICFN static
  93. #define STATICDT static
  94. #endif //WIN32
  95. #define FASTCALL __fastcall
  96. #define _FASTCALL __fastcall
  97. #if !defined NUMELMS
  98. #define NUMELMS(aa) (sizeof(aa)/sizeof((aa)[0]))
  99. #endif
  100. #ifdef WIN32
  101. /* --- Win32 version --------------------------------------------------- */
  102. #include <string.h>
  103. #include <memory.h>
  104. #undef CDECL
  105. #ifdef MIPS
  106. #define __stdcall
  107. #define _stdcall
  108. #define _cdecl
  109. #define __cdecl
  110. #define CDECL
  111. #else
  112. #define CDECL _cdecl
  113. #endif
  114. //typedef BITMAPINFOHEADER FAR *LPBITMAPINFOHEADER;
  115. #define far
  116. #define _far
  117. #define __far
  118. #define HUGE_T
  119. #define HUGE
  120. #define huge
  121. #define _huge
  122. #define __huge
  123. #define near
  124. #define _near
  125. #define __near
  126. #define _fastcall
  127. #define __fastcall
  128. #define _loadds
  129. #define __loadds
  130. #define _LOADDS
  131. #define LOADDS
  132. #define _export //should _export be blank?
  133. #define __export
  134. #define EXPORT
  135. #define _based(x)
  136. #define __based(x)
  137. #define _based32(x)
  138. #define __based32(x)
  139. #ifdef _X86_
  140. // __inline provides speed improvements for x86 platforms. Unfortunately
  141. // the MIPS compiler does not have inline support. Alpha is unknown, so
  142. // we do not assume and play it safe.
  143. #define INLINE __inline
  144. #define inline __inline
  145. #define _inline __inline
  146. #else
  147. #define INLINE
  148. #define inline
  149. #define _inline
  150. #define __inline
  151. #endif
  152. //typedef RGBQUAD FAR *LPRGBQUAD;
  153. #ifdef DAYTONA
  154. typedef LRESULT (*DRIVERPROC)(DWORD, HDRVR, UINT, WPARAM, LPARAM);
  155. #endif
  156. #define GetCurrentTask() (HTASK)GetCurrentThreadId()
  157. #define WF_PMODE 0x0001
  158. #define WF_CPU286 0x0002
  159. #define WF_CPU386 0x0004
  160. #define WF_CPU486 0x0008
  161. #define WF_80x87 0x0400
  162. #define WF_PAGING 0x0800
  163. #define GetWinFlags() (WF_PMODE|WF_CPU486|WF_PAGING|WF_80x87)
  164. //#define hmemcpy memcpy
  165. #define _fmemcpy memcpy
  166. #define _fmemset memset
  167. //#define lstrcpyn(dest, source, cb) ( strncpy(dest, source, cb), ((char *) dest) [cb - 1] = 0)
  168. //!!! should use LARGE_INTEGER stuff.
  169. #define muldiv32 MulDiv
  170. #define muldivru32(a,b,c) (long)(((double)(a) * (double)(b) + (double)((c)-1)) / (double)(c))
  171. #define muldivrd32(a,b,c) (long)(((double)(a) * (double)(b)) / (double)(c))
  172. #define IsTask(x) ((x) != 0)
  173. #define IsGDIObject(obj) (GetObjectType((HGDIOBJ)(obj)) != 0)
  174. #define SZCODEA CHAR
  175. #define SZCODE TCHAR
  176. typedef TCHAR * NPTSTR;
  177. #ifndef UNICODE
  178. // !!!!!!! need lstrcpyW, lstrlenW, wsprintfW, lstrcpynW for Chicago!
  179. #endif
  180. #else
  181. /* --- Win16 version --------------------------------------------------- */
  182. #include <string.h>
  183. #include <memory.h>
  184. #define SZCODEA SZCODE
  185. typedef char TCHAR;
  186. typedef WORD WCHAR;
  187. typedef NPSTR NPTSTR;
  188. typedef LPSTR LPTSTR;
  189. typedef LPSTR LPOLESTR;
  190. typedef LPCSTR LPCOLESTR;
  191. typedef char OLECHAR;
  192. typedef int INT;
  193. #define _LOADDS _loadds
  194. #define LOADDS _loadds
  195. #define EXPORT _export
  196. #define HUGE _huge
  197. #define DRIVERS_SECTION "Drivers"
  198. #define MCI_SECTION "MCI"
  199. #define MCIAVI_SECTION "MCIAVI"
  200. #define TEXT(sz) sz
  201. // stuff in muldiv32.asm
  202. EXTERN_C LONG FAR PASCAL muldiv32(LONG,LONG,LONG);
  203. EXTERN_C LONG FAR PASCAL muldivru32(LONG,LONG,LONG);
  204. EXTERN_C LONG FAR PASCAL muldivrd32(LONG,LONG,LONG);
  205. #define UNALIGNED
  206. #define INLINE __inline
  207. #define CharPrev AnsiPrev
  208. /*
  209. * define these so we can explicitly use Ansi or Unicode versions
  210. * in the NT code, and the standard entry point for Win16.
  211. */
  212. #define SetWindowTextA SetWindowText
  213. #define GetProfileStringA GetProfileString
  214. #define GetPrivateProfileStringA GetPrivateProfileString
  215. #define GetProfileIntA GetProfileInt
  216. #define GetModuleHandleA GetModuleHandle
  217. #define GetModuleFileNameA GetModuleFileName
  218. #define wvsprintfA wvsprintf
  219. #define wsprintfA wsprintf
  220. #define lstrcmpA lstrcmp
  221. #define lstrcmpiA lstrcmpi
  222. #define lstrcpyA lstrcpy
  223. #define lstrcatA lstrcat
  224. #define lstrlenA lstrlen
  225. #define LoadStringA LoadString
  226. #define LoadStringW LoadString
  227. #define OutputDebugStringA OutputDebugString
  228. #define MessageBoxA MessageBox
  229. // Needed for writing OLE-style code that builds 16/32....
  230. #define lstrcpyW lstrcpy
  231. #define lstrcpynW lstrcpyn
  232. #define lstrlenW lstrlen
  233. #define SZCODE char _based(_segname("_CODE"))
  234. #define LPCWSTR LPCSTR
  235. #define LPCTSTR LPCSTR
  236. #define LPWSTR LPSTR
  237. #define PTSTR PSTR
  238. /****** Alternate porting layer macros ****************************************/
  239. #ifndef GET_WPARAM
  240. /* USER MESSAGES: */
  241. #define GET_WPARAM(wp, lp) (wp)
  242. #define GET_LPARAM(wp, lp) (lp)
  243. #define GET_WM_ACTIVATE_STATE(wp, lp) (wp)
  244. #define GET_WM_ACTIVATE_FMINIMIZED(wp, lp) (BOOL)HIWORD(lp)
  245. #define GET_WM_ACTIVATE_HWND(wp, lp) (HWND)LOWORD(lp)
  246. #define GET_WM_ACTIVATE_MPS(s, fmin, hwnd) \
  247. (WPARAM)(s), MAKELONG(hwnd, fmin)
  248. #define GET_WM_CHARTOITEM_CHAR(wp, lp) (CHAR)(wp)
  249. #define GET_WM_CHARTOITEM_POS(wp, lp) HIWORD(lp)
  250. #define GET_WM_CHARTOITEM_HWND(wp, lp) (HWND)LOWORD(lp)
  251. #define GET_WM_CHARTOITEM_MPS(ch, pos, hwnd) \
  252. (WPARAM)(ch), MAKELONG(hwnd, pos)
  253. #define GET_WM_COMMAND_ID(wp, lp) (wp)
  254. #define GET_WM_COMMAND_HWND(wp, lp) (HWND)LOWORD(lp)
  255. #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(lp)
  256. #define GET_WM_COMMAND_MPS(id, hwnd, cmd) \
  257. (WPARAM)(id), MAKELONG(hwnd, cmd)
  258. #define WM_CTLCOLORMSGBOX 0x0132
  259. #define WM_CTLCOLOREDIT 0x0133
  260. #define WM_CTLCOLORLISTBOX 0x0134
  261. #define WM_CTLCOLORBTN 0x0135
  262. #define WM_CTLCOLORDLG 0x0136
  263. #define WM_CTLCOLORSCROLLBAR 0x0137
  264. #define WM_CTLCOLORSTATIC 0x0138
  265. #define GET_WM_CTLCOLOR_HDC(wp, lp, msg) (HDC)(wp)
  266. #define GET_WM_CTLCOLOR_HWND(wp, lp, msg) (HWND)LOWORD(lp)
  267. #define GET_WM_CTLCOLOR_TYPE(wp, lp, msg) HIWORD(lp)
  268. #define GET_WM_CTLCOLOR_MPS(hdc, hwnd, type) \
  269. (WPARAM)(hdc), MAKELONG(hwnd, type)
  270. #define GET_WM_MENUSELECT_CMD(wp, lp) (wp)
  271. #define GET_WM_MENUSELECT_FLAGS(wp, lp) LOWORD(lp)
  272. #define GET_WM_MENUSELECT_HMENU(wp, lp) (HMENU)HIWORD(lp)
  273. #define GET_WM_MENUSELECT_MPS(cmd, f, hmenu) \
  274. (WPARAM)(cmd), MAKELONG(f, hmenu)
  275. // Note: the following are for interpreting MDIclient to MDI child messages.
  276. #define GET_WM_MDIACTIVATE_FACTIVATE(hwnd, wp, lp) (BOOL)(wp)
  277. #define GET_WM_MDIACTIVATE_HWNDDEACT(wp, lp) (HWND)HIWORD(lp)
  278. #define GET_WM_MDIACTIVATE_HWNDACTIVATE(wp, lp) (HWND)LOWORD(lp)
  279. // Note: the following is for sending to the MDI client window.
  280. #define GET_WM_MDIACTIVATE_MPS(f, hwndD, hwndA)\
  281. (WPARAM)(hwndA), 0
  282. #define GET_WM_MDISETMENU_MPS(hmenuF, hmenuW) 0, MAKELONG(hmenuF, hmenuW)
  283. #define GET_WM_MENUCHAR_CHAR(wp, lp) (CHAR)(wp)
  284. #define GET_WM_MENUCHAR_HMENU(wp, lp) (HMENU)LOWORD(lp)
  285. #define GET_WM_MENUCHAR_FMENU(wp, lp) (BOOL)HIWORD(lp)
  286. #define GET_WM_MENUCHAR_MPS(ch, hmenu, f) \
  287. (WPARAM)(ch), MAKELONG(hmenu, f)
  288. #define GET_WM_PARENTNOTIFY_MSG(wp, lp) (wp)
  289. #define GET_WM_PARENTNOTIFY_ID(wp, lp) HIWORD(lp)
  290. #define GET_WM_PARENTNOTIFY_HWNDCHILD(wp, lp) (HWND)LOWORD(lp)
  291. #define GET_WM_PARENTNOTIFY_X(wp, lp) (INT)LOWORD(lp)
  292. #define GET_WM_PARENTNOTIFY_Y(wp, lp) (INT)HIWORD(lp)
  293. #define GET_WM_PARENTNOTIFY_MPS(msg, id, hwnd) \
  294. (WPARAM)(msg), MAKELONG(hwnd, id)
  295. #define GET_WM_PARENTNOTIFY2_MPS(msg, x, y) \
  296. (WPARAM)(msg), MAKELONG(x, y)
  297. #define GET_WM_VKEYTOITEM_CODE(wp, lp) (wp)
  298. #define GET_WM_VKEYTOITEM_ITEM(wp, lp) (INT)HIWORD(lp)
  299. #define GET_WM_VKEYTOITEM_HWND(wp, lp) (HWND)LOWORD(lp)
  300. #define GET_WM_VKEYTOITEM_MPS(code, item, hwnd) \
  301. (WPARAM)(code), MAKELONG(hwnd, item)
  302. #define GET_EM_SETSEL_START(wp, lp) LOWORD(lp)
  303. #define GET_EM_SETSEL_END(wp, lp) HIWORD(lp)
  304. #define GET_EM_SETSEL_MPS(iStart, iEnd) \
  305. 0, MAKELONG(iStart, iEnd)
  306. #define GET_EM_LINESCROLL_MPS(vert, horz) \
  307. 0, MAKELONG(vert, horz)
  308. #define GET_WM_CHANGECBCHAIN_HWNDNEXT(wp, lp) (HWND)LOWORD(lp)
  309. #define GET_WM_HSCROLL_CODE(wp, lp) (wp)
  310. #define GET_WM_HSCROLL_POS(wp, lp) LOWORD(lp)
  311. #define GET_WM_HSCROLL_HWND(wp, lp) (HWND)HIWORD(lp)
  312. #define GET_WM_HSCROLL_MPS(code, pos, hwnd) \
  313. (WPARAM)(code), MAKELONG(pos, hwnd)
  314. #define GET_WM_VSCROLL_CODE(wp, lp) (wp)
  315. #define GET_WM_VSCROLL_POS(wp, lp) LOWORD(lp)
  316. #define GET_WM_VSCROLL_HWND(wp, lp) (HWND)HIWORD(lp)
  317. #define GET_WM_VSCROLL_MPS(code, pos, hwnd) \
  318. (WPARAM)(code), MAKELONG(pos, hwnd)
  319. #endif // !GET_WPARAM
  320. #endif // !WIN32
  321. #endif