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.

326 lines
10 KiB

  1. //==========================================================================;
  2. //
  3. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. // PURPOSE.
  7. //
  8. // Copyright (c) 1992 - 1994 Microsoft Corporation. All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------;
  11. //
  12. // appport.h
  13. //
  14. // Description:
  15. // Win 16/32 Portability Stuff
  16. //
  17. // This file contains common macros to help with writing code that
  18. // cross compiles between Win 32 and Win 16. This file should be
  19. // included _after_ windows.h and windowsx.h.
  20. //
  21. //==========================================================================;
  22. #ifndef _INC_APPPORT
  23. #define _INC_APPPORT // #defined if file has been included
  24. #ifndef RC_INVOKED
  25. #pragma pack(1) // assume byte packing throughout
  26. #endif
  27. #ifndef EXTERN_C
  28. #ifdef __cplusplus
  29. #define EXTERN_C extern "C"
  30. #else
  31. #define EXTERN_C extern
  32. #endif
  33. #endif
  34. #ifdef __cplusplus
  35. extern "C" // assume C declarations for C++
  36. {
  37. #endif
  38. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  39. //
  40. // Win 32
  41. //
  42. //
  43. //
  44. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  45. #ifdef WIN32
  46. #ifndef FNLOCAL
  47. #ifdef DEBUG
  48. #define FNLOCAL _stdcall
  49. #define FNCLOCAL _stdcall
  50. #else
  51. #define FNLOCAL static _stdcall
  52. #define FNCLOCAL static _stdcall
  53. #endif
  54. #define FNGLOBAL _stdcall
  55. #define FNCGLOBAL _stdcall
  56. #define FNWCALLBACK CALLBACK
  57. #define FNEXPORT CALLBACK
  58. #endif
  59. #include <tchar.h>
  60. //
  61. //
  62. //
  63. #define Edit_GetSelEx(hwndCtl, pnS, pnE) \
  64. ((DWORD)SendMessage((hwndCtl), EM_GETSEL, (WPARAM)pnS, (LPARAM)pnE))
  65. #define HUGE
  66. //
  67. // for compiling Unicode
  68. //
  69. #ifdef UNICODE
  70. #define SIZEOF(x) (sizeof(x)/sizeof(WCHAR))
  71. #else
  72. #define SIZEOF(x) sizeof(x)
  73. #endif
  74. #define BCODE
  75. #define BDATA
  76. #define BSTACK
  77. //
  78. // win32 apps [usually] don't have to worry about 'huge' data
  79. //
  80. #if !defined hmemcpy
  81. #define hmemcpy memcpy
  82. #endif
  83. #endif // #ifdef WIN32
  84. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  85. //
  86. // Win 16
  87. //
  88. //
  89. //
  90. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  91. #ifndef WIN32
  92. #ifndef FNLOCAL
  93. #ifdef DEBUG
  94. #define FNLOCAL NEAR PASCAL
  95. #define FNCLOCAL NEAR _cdecl
  96. #else
  97. #define FNLOCAL static NEAR PASCAL
  98. #define FNCLOCAL static NEAR _cdecl
  99. #endif
  100. #define FNGLOBAL FAR PASCAL
  101. #define FNCGLOBAL FAR _cdecl
  102. #ifdef _WINDLL
  103. #define FNWCALLBACK FAR PASCAL _loadds
  104. #define FNEXPORT FAR PASCAL _export
  105. #else
  106. #define FNWCALLBACK FAR PASCAL _export
  107. #define FNEXPORT FAR PASCAL _export
  108. #endif
  109. #endif
  110. #ifndef _tcstod
  111. #define _tcstod strtod
  112. #define _tcstol strtol
  113. #define _tcstoul strtoul
  114. #endif
  115. //
  116. //
  117. //
  118. //
  119. #ifndef NOXACTALLC
  120. #undef GlobalAllocPtr
  121. #undef GlobalReAllocPtr
  122. static __inline LPVOID GlobalExactLock(HGLOBAL hg, DWORD cb)
  123. {
  124. return (LPVOID)((hg) ? (LPVOID)((LPBYTE)GlobalLock(hg) + (GlobalSize(hg) - (cb))) : (LPVOID)NULL);
  125. }
  126. #define GlobalAllocPtr(flags, cb) \
  127. (GlobalExactLock(GlobalAlloc((flags), (cb)), (cb)))
  128. #define GlobalReAllocPtr(lp, cbNew, flags) \
  129. (GlobalUnlockPtr(lp), GlobalExactLock(GlobalReAlloc(GlobalPtrHandle(lp) , (cbNew), (flags)), (cbNew)))
  130. #endif
  131. //
  132. //
  133. //
  134. //
  135. #ifndef FIELD_OFFSET
  136. #define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field))
  137. #endif
  138. //
  139. // based code makes since only in win 16 (to try and keep stuff out of
  140. // our fixed data segment...
  141. //
  142. #define BCODE _based(_segname("_CODE"))
  143. #define BDATA _based(_segname("_DATA"))
  144. #define BSTACK _based(_segname("_STACK"))
  145. #define HUGE _huge
  146. #define UNALIGNED
  147. //
  148. // stuff for Unicode in Win 32--make it a noop in Win 16
  149. //
  150. #ifndef _TCHAR_DEFINED
  151. #define _TCHAR_DEFINED
  152. typedef char TCHAR, *PTCHAR;
  153. typedef unsigned char TBYTE, *PTUCHAR;
  154. typedef PSTR PTSTR, PTCH;
  155. typedef LPSTR LPTSTR, LPTCH;
  156. typedef LPCSTR LPCTSTR;
  157. #endif
  158. #ifndef _MMRESULT_
  159. #define _MMRESULT_
  160. typedef UINT MMRESULT;
  161. #endif
  162. #define TEXT(a) a
  163. #define SIZEOF(x) sizeof(x)
  164. //
  165. //
  166. //
  167. #define CharNext AnsiNext
  168. #define CharPrev AnsiPrev
  169. //
  170. //
  171. //
  172. #define Edit_GetSelEx(hwndCtl, pnS, pnE) \
  173. { \
  174. DWORD dw; \
  175. dw = (DWORD)SendMessage((hwndCtl), EM_GETSEL, 0, 0L); \
  176. *pnE = (int)HIWORD(dw); \
  177. *pnS = (int)LOWORD(dw); \
  178. }
  179. //
  180. // common message cracker macros available in windowx.h on NT--these
  181. // should be added to the Win 16 windowsx.h and probably will be
  182. // in the future.
  183. //
  184. // there is a windowsx.h16 that ships with the NT PDK that defines
  185. // these macros. so if that version is being used, don't redefine
  186. // message crackers.
  187. //
  188. #ifndef WM_CTLCOLORMSGBOX
  189. #define WM_CTLCOLORMSGBOX 0x0132
  190. #define WM_CTLCOLOREDIT 0x0133
  191. #define WM_CTLCOLORLISTBOX 0x0134
  192. #define WM_CTLCOLORBTN 0x0135
  193. #define WM_CTLCOLORDLG 0x0136
  194. #define WM_CTLCOLORSCROLLBAR 0x0137
  195. #define WM_CTLCOLORSTATIC 0x0138
  196. #endif
  197. #ifndef GET_WM_ACTIVATE_STATE
  198. #define GET_WM_ACTIVATE_STATE(wp, lp) (wp)
  199. #define GET_WM_ACTIVATE_FMINIMIZED(wp, lp) (BOOL)HIWORD(lp)
  200. #define GET_WM_ACTIVATE_HWND(wp, lp) (HWND)LOWORD(lp)
  201. #define GET_WM_ACTIVATE_MPS(s, fmin, hwnd) (WPARAM)(s), MAKELONG(hwnd, fmin)
  202. #define GET_WM_CHARTOITEM_CHAR(wp, lp) (CHAR)(wp)
  203. #define GET_WM_CHARTOITEM_POS(wp, lp) HIWORD(lp)
  204. #define GET_WM_CHARTOITEM_HWND(wp, lp) (HWND)LOWORD(lp)
  205. #define GET_WM_CHARTOITEM_MPS(ch, pos, hwnd) (WPARAM)(ch), MAKELONG(hwnd, pos)
  206. #define GET_WM_COMMAND_ID(wp, lp) (wp)
  207. #define GET_WM_COMMAND_HWND(wp, lp) (HWND)LOWORD(lp)
  208. #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(lp)
  209. #define GET_WM_COMMAND_MPS(id, hwnd, cmd) (WPARAM)(id), MAKELONG(hwnd, cmd)
  210. #define GET_WM_CTLCOLOR_HDC(wp, lp, msg) (HDC)(wp)
  211. #define GET_WM_CTLCOLOR_HWND(wp, lp, msg) (HWND)LOWORD(lp)
  212. #define GET_WM_CTLCOLOR_TYPE(wp, lp, msg) HIWORD(lp)
  213. #define GET_WM_CTLCOLOR_MPS(hdc, hwnd, type) (WPARAM)(hdc), MAKELONG(hwnd, type)
  214. #define GET_WM_MENUSELECT_CMD(wp, lp) (wp)
  215. #define GET_WM_MENUSELECT_FLAGS(wp, lp) LOWORD(lp)
  216. #define GET_WM_MENUSELECT_HMENU(wp, lp) (HMENU)HIWORD(lp)
  217. #define GET_WM_MENUSELECT_MPS(cmd, f, hmenu) (WPARAM)(cmd), MAKELONG(f, hmenu)
  218. // Note: the following are for interpreting MDIclient to MDI child messages.
  219. #define GET_WM_MDIACTIVATE_FACTIVATE(hwnd, wp, lp) (BOOL)(wp)
  220. #define GET_WM_MDIACTIVATE_HWNDDEACT(wp, lp) (HWND)HIWORD(lp)
  221. #define GET_WM_MDIACTIVATE_HWNDACTIVATE(wp, lp) (HWND)LOWORD(lp)
  222. // Note: the following is for sending to the MDI client window.
  223. #define GET_WM_MDIACTIVATE_MPS(f, hwndD, hwndA) (WPARAM)(hwndA), 0
  224. #define GET_WM_MDISETMENU_MPS(hmenuF, hmenuW) 0, MAKELONG(hmenuF, hmenuW)
  225. #define GET_WM_MENUCHAR_CHAR(wp, lp) (CHAR)(wp)
  226. #define GET_WM_MENUCHAR_HMENU(wp, lp) (HMENU)LOWORD(lp)
  227. #define GET_WM_MENUCHAR_FMENU(wp, lp) (BOOL)HIWORD(lp)
  228. #define GET_WM_MENUCHAR_MPS(ch, hmenu, f) (WPARAM)(ch), MAKELONG(hmenu, f)
  229. #define GET_WM_PARENTNOTIFY_MSG(wp, lp) (wp)
  230. #define GET_WM_PARENTNOTIFY_ID(wp, lp) HIWORD(lp)
  231. #define GET_WM_PARENTNOTIFY_HWNDCHILD(wp, lp) (HWND)LOWORD(lp)
  232. #define GET_WM_PARENTNOTIFY_X(wp, lp) (INT)LOWORD(lp)
  233. #define GET_WM_PARENTNOTIFY_Y(wp, lp) (INT)HIWORD(lp)
  234. #define GET_WM_PARENTNOTIFY_MPS(msg, id, hwnd) (WPARAM)(msg), MAKELONG(hwnd, id)
  235. #define GET_WM_PARENTNOTIFY2_MPS(msg, x, y) (WPARAM)(msg), MAKELONG(x, y)
  236. #define GET_WM_VKEYTOITEM_CODE(wp, lp) (wp)
  237. #define GET_WM_VKEYTOITEM_ITEM(wp, lp) (INT)HIWORD(lp)
  238. #define GET_WM_VKEYTOITEM_HWND(wp, lp) (HWND)LOWORD(lp)
  239. #define GET_WM_VKEYTOITEM_MPS(code, item, hwnd) (WPARAM)(code), MAKELONG(hwnd, item)
  240. #define GET_EM_SETSEL_START(wp, lp) LOWORD(lp)
  241. #define GET_EM_SETSEL_END(wp, lp) HIWORD(lp)
  242. #define GET_EM_SETSEL_MPS(iStart, iEnd) 0, MAKELONG(iStart, iEnd)
  243. #define GET_EM_LINESCROLL_MPS(vert, horz) 0, MAKELONG(vert, horz)
  244. #define GET_WM_CHANGECBCHAIN_HWNDNEXT(wp, lp) (HWND)LOWORD(lp)
  245. #define GET_WM_HSCROLL_CODE(wp, lp) (wp)
  246. #define GET_WM_HSCROLL_POS(wp, lp) LOWORD(lp)
  247. #define GET_WM_HSCROLL_HWND(wp, lp) (HWND)HIWORD(lp)
  248. #define GET_WM_HSCROLL_MPS(code, pos, hwnd) (WPARAM)(code), MAKELONG(pos, hwnd)
  249. #define GET_WM_VSCROLL_CODE(wp, lp) (wp)
  250. #define GET_WM_VSCROLL_POS(wp, lp) LOWORD(lp)
  251. #define GET_WM_VSCROLL_HWND(wp, lp) (HWND)HIWORD(lp)
  252. #define GET_WM_VSCROLL_MPS(code, pos, hwnd) (WPARAM)(code), MAKELONG(pos, hwnd)
  253. #endif
  254. #endif // #ifndef WIN32
  255. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  256. //
  257. //
  258. //
  259. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  260. #ifndef RC_INVOKED
  261. #pragma pack() // revert to default packing
  262. #endif
  263. #ifdef __cplusplus
  264. } // end of extern "C" {
  265. #endif
  266. #endif // _INC_APPPORT