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.

294 lines
14 KiB

  1. /*****************************************************************************\
  2. * Copyright (C) Microsoft Corporation, 1990-1999
  3. * PWIN16.H - PORTABILITY MAPPING HEADER FILE
  4. *
  5. * This file provides macros to map portable windows code to its 16 bit form.
  6. \*****************************************************************************/
  7. #if _MSC_VER > 1000
  8. #pragma once
  9. #endif
  10. /*-----------------------------------USER------------------------------------*/
  11. DWORD FAR PASCAL MGetLastError(VOID);
  12. DWORD FAR PASCAL MSendMsgEM_GETSEL(HWND hDlg, INT FAR *piStart, INT FAR *piEnd);
  13. /* HELPER MACROS */
  14. #define MAPVALUE(v16, v32) (v16)
  15. #define MAPTYPE(v16, v32) v16
  16. #define MAKEMPOINT(l) (*((MPOINT FAR *)&(l)))
  17. #define MPOINT2POINT(mpt, pt) (pt = *(POINT FAR *)&(mpt))
  18. #define POINT2MPOINT(pt, mpt) (mpt = *(MPOINT FAR *)&(pt))
  19. #define LONG2POINT(l, pt) ((pt).x = (INT)LOWORD(l), (pt).y = (INT)HIWORD(l))
  20. #define GETWINDOWUINT(hwnd, index) (UINT)GetWindowWord(hwnd, index)
  21. #define SETWINDOWUINT(hwnd, index, ui) (UINT)SetWindowWord(hwnd, index, (WORD)(ui))
  22. #define SETCLASSUINT(hwnd, index, ui) (UINT)SetClassWord(hwnd, index, (WORD)(ui))
  23. #define GETCLASSUINT(hwnd, index) (UINT)GetClassWord(hwnd, index)
  24. #define GETCBCLSEXTRA(hwnd) GETCLASSUINT(hwnd, GCW_CBCLSEXTRA)
  25. #define SETCBCLSEXTRA(hwnd, cb) SETCLASSUINT(hwnd, GCW_CBCLSEXTRA, cb)
  26. #define GETCBWNDEXTRA(hwnd) GETCLASSUINT(hwnd, GCW_CBWNDEXTRA)
  27. #define SETCBWNDEXTRA(hwnd, cb) SETCLASSUINT(hwnd, GCW_CBWNDEXTRA, cb)
  28. #define GETCLASSBRBACKGROUND(hwnd) (HBRUSH)GETCLASSUINT(hwnd, GCW_HBRBACKGROUND)
  29. #define SETCLASSBRBACKGROUND(hwnd, h) (HBRUSH)SETCLASSUINT(hwnd, GCW_HBRBACKGROUND, h)
  30. #define GETCLASSCURSOR(hwnd) (HCURSOR)GETCLASSUINT(hwnd, GCW_HCURSOR)
  31. #define SETCLASSCURSOR(hwnd, h) (HCURSOR)SETCLASSUINT(hwnd, GCW_HCURSOR, h)
  32. #define GETCLASSHMODULE(hwnd) (HMODULE)GETCLASSUINT(hwnd, GCW_HMODULE)
  33. #define SETCLASSHMODULE(hwnd, h) (HMODULE)SETCLASSUINT(hwnd, GCW_HMODULE, h)
  34. #define GETCLASSICON(hwnd) (HICON)GETCLASSUINT((hwnd), GCW_HICON)
  35. #define SETCLASSICON(hwnd, h) (HICON)SETCLASSUINT((hwnd), GCW_HICON, h)
  36. #define GETCLASSSTYLE(hwnd) GETCLASSUINT((hwnd), GCW_STYLE)
  37. #define SETCLASSSTYLE(hwnd, style) SETCLASSUINT((hwnd), GCW_STYLE, style)
  38. #define GETHWNDINSTANCE(hwnd) (HMODULE)GETWINDOWUINT((hwnd), GWW_HINSTANCE)
  39. #define SETHWNDINSTANCE(hwnd, h) (HMODULE)SETWINDOWUINT((hwnd), GWW_HINSTANCE, h)
  40. #define GETHWNDPARENT(hwnd) (HWND)GETWINDOWUINT((hwnd), GWW_HWNDPARENT)
  41. #define SETHWNDPARENT(hwnd, h) (HWND)SETWINDOWUINT((hwnd), GWW_HWNDPARENT, h)
  42. #define GETWINDOWID(hwnd) GETWINDOWUINT((hwnd), GWW_ID)
  43. #define SETWINDOWID(hwnd, id) SETWINDOWUINT((hwnd), GWW_ID, id)
  44. /* USER API */
  45. #define MDlgDirSelect(hDlg, lpstr, nLength, nIDListBox) \
  46. DlgDirSelect(hDlg, lpstr, nIDListBox)
  47. #define MDlgDirSelectCOMBOBOX(hDlg, lpstr, nLength, nIDComboBox) \
  48. DlgDirSelectComboBox(hDlg, lpstr, nIDComboBox)
  49. #define MMain(hInst, hPrevInst, lpCmdLine, nCmdShow) \
  50. INT PASCAL WinMain(HANDLE hInst, HANDLE hPrevInst, LPSTR lpCmdLine, \
  51. INT nCmdShow) { \
  52. INT _argc; \
  53. CHAR **_argv;
  54. /* USER MESSAGES: */
  55. #define GET_WPARAM(wp, lp) (wp)
  56. #define GET_LPARAM(wp, lp) (lp)
  57. #define WM_CTLCOLORMSGBOX 0x0132
  58. #define WM_CTLCOLOREDIT 0x0133
  59. #define WM_CTLCOLORLISTBOX 0x0134
  60. #define WM_CTLCOLORBTN 0x0135
  61. #define WM_CTLCOLORDLG 0x0136
  62. #define WM_CTLCOLORSCROLLBAR 0x0137
  63. #define WM_CTLCOLORSTATIC 0x0138
  64. #define GET_WM_ACTIVATE_STATE(wp, lp) (wp)
  65. #define GET_WM_ACTIVATE_FMINIMIZED(wp, lp) (BOOL)HIWORD(lp)
  66. #define GET_WM_ACTIVATE_HWND(wp, lp) (HWND)LOWORD(lp)
  67. #define GET_WM_ACTIVATE_MPS(s, fmin, hwnd) \
  68. (WPARAM)(s), MAKELONG(hwnd, fmin)
  69. #define GET_WM_CHARTOITEM_CHAR(wp, lp) (CHAR)(wp)
  70. #define GET_WM_CHARTOITEM_POS(wp, lp) HIWORD(lp)
  71. #define GET_WM_CHARTOITEM_HWND(wp, lp) (HWND)LOWORD(lp)
  72. #define GET_WM_CHARTOITEM_MPS(ch, pos, hwnd) \
  73. (WPARAM)(ch), MAKELONG(hwnd, pos)
  74. #define GET_WM_COMMAND_ID(wp, lp) (wp)
  75. #define GET_WM_COMMAND_HWND(wp, lp) (HWND)LOWORD(lp)
  76. #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(lp)
  77. #define GET_WM_COMMAND_MPS(id, hwnd, cmd) \
  78. (WPARAM)(id), MAKELONG(hwnd, cmd)
  79. #define GET_WM_CTLCOLOR_HDC(wp, lp, msg) (HDC)(wp)
  80. #define GET_WM_CTLCOLOR_HWND(wp, lp, msg) (HWND)LOWORD(lp)
  81. #define GET_WM_CTLCOLOR_TYPE(wp, lp, msg) HIWORD(lp)
  82. #define GET_WM_CTLCOLOR_MPS(hdc, hwnd, type) \
  83. (WPARAM)(hdc), MAKELONG(hwnd, type)
  84. #define GET_WM_MENUSELECT_CMD(wp, lp) (wp)
  85. #define GET_WM_MENUSELECT_FLAGS(wp, lp) LOWORD(lp)
  86. #define GET_WM_MENUSELECT_HMENU(wp, lp) (HMENU)HIWORD(lp)
  87. #define GET_WM_MENUSELECT_MPS(cmd, f, hmenu) \
  88. (WPARAM)(cmd), MAKELONG(f, hmenu)
  89. // Note: the following are for interpreting MDIclient to MDI child messages.
  90. #define GET_WM_MDIACTIVATE_FACTIVATE(hwnd, wp, lp) (BOOL)(wp)
  91. #define GET_WM_MDIACTIVATE_HWNDDEACT(wp, lp) (HWND)HIWORD(lp)
  92. #define GET_WM_MDIACTIVATE_HWNDACTIVATE(wp, lp) (HWND)LOWORD(lp)
  93. // Note: the following is for sending to the MDI client window.
  94. #define GET_WM_MDIACTIVATE_MPS(f, hwndD, hwndA)\
  95. (WPARAM)(hwndA), 0
  96. #define GET_WM_MDISETMENU_MPS(hmenuF, hmenuW) 0, MAKELONG(hmenuF, hmenuW)
  97. #define GET_WM_MENUCHAR_CHAR(wp, lp) (CHAR)(wp)
  98. #define GET_WM_MENUCHAR_HMENU(wp, lp) (HMENU)LOWORD(lp)
  99. #define GET_WM_MENUCHAR_FMENU(wp, lp) (BOOL)HIWORD(lp)
  100. #define GET_WM_MENUCHAR_MPS(ch, hmenu, f) \
  101. (WPARAM)(ch), MAKELONG(hmenu, f)
  102. #define GET_WM_PARENTNOTIFY_MSG(wp, lp) (wp)
  103. #define GET_WM_PARENTNOTIFY_ID(wp, lp) HIWORD(lp)
  104. #define GET_WM_PARENTNOTIFY_HWNDCHILD(wp, lp) (HWND)LOWORD(lp)
  105. #define GET_WM_PARENTNOTIFY_X(wp, lp) (INT)LOWORD(lp)
  106. #define GET_WM_PARENTNOTIFY_Y(wp, lp) (INT)HIWORD(lp)
  107. #define GET_WM_PARENTNOTIFY_MPS(msg, id, hwnd) \
  108. (WPARAM)(msg), MAKELONG(hwnd, id)
  109. #define GET_WM_PARENTNOTIFY2_MPS(msg, x, y) \
  110. (WPARAM)(msg), MAKELONG(x, y)
  111. #define GET_WM_VKEYTOITEM_CODE(wp, lp) (wp)
  112. #define GET_WM_VKEYTOITEM_ITEM(wp, lp) (INT)HIWORD(lp)
  113. #define GET_WM_VKEYTOITEM_HWND(wp, lp) (HWND)LOWORD(lp)
  114. #define GET_WM_VKEYTOITEM_MPS(code, item, hwnd) \
  115. (WPARAM)(code), MAKELONG(hwnd, item)
  116. #define GET_EM_SETSEL_START(wp, lp) LOWORD(lp)
  117. #define GET_EM_SETSEL_END(wp, lp) HIWORD(lp)
  118. #define GET_EM_SETSEL_MPS(iStart, iEnd) \
  119. 0, MAKELONG(iStart, iEnd)
  120. #define GET_EM_LINESCROLL_MPS(vert, horz) \
  121. 0, MAKELONG(vert, horz)
  122. #define GET_WM_HSCROLL_CODE(wp, lp) (wp)
  123. #define GET_WM_HSCROLL_POS(wp, lp) LOWORD(lp)
  124. #define GET_WM_HSCROLL_HWND(wp, lp) (HWND)HIWORD(lp)
  125. #define GET_WM_HSCROLL_MPS(code, pos, hwnd) \
  126. (WPARAM)(code), MAKELONG(pos, hwnd)
  127. #define GET_WM_VSCROLL_CODE(wp, lp) (wp)
  128. #define GET_WM_VSCROLL_POS(wp, lp) LOWORD(lp)
  129. #define GET_WM_VSCROLL_HWND(wp, lp) (HWND)HIWORD(lp)
  130. #define GET_WM_VSCROLL_MPS(code, pos, hwnd) \
  131. (WPARAM)(code), MAKELONG(pos, hwnd)
  132. #define GET_WM_CHANGECBCHAIN_HWNDNEXT(wp, lp) (HWND)LOWORD(lp)
  133. #define DDEFREE(msg, lp)
  134. #define GET_WM_DDE_ACK_STATUS(wp, lp) LOWORD(lp)
  135. #define GET_WM_DDE_ACK_ITEM(wp, lp) (ATOM)HIWORD(lp)
  136. #define MPostWM_DDE_ACK(hTo, hFrom, wStatus, aItem) \
  137. PostMessage(hTo, WM_DDE_ACK, (WPARAM)hFrom, MAKELONG(wStatus, aItem))
  138. #define GET_WM_DDE_ADVISE_HOPTIONS(wp, lp) (HANDLE)LOWORD(lp)
  139. #define GET_WM_DDE_ADVISE_ITEM(wp, lp) (ATOM)HIWORD(lp)
  140. #define MPostWM_DDE_ADVISE(hTo, hFrom, hOptions, aItem) \
  141. PostMessage(hTo, WM_DDE_ADVISE, (WPARAM)hFrom, MAKELONG(hOptions, aItem))
  142. #define GET_WM_DDE_DATA_HDATA(wp, lp) (HANDLE)LOWORD(lp)
  143. #define GET_WM_DDE_DATA_ITEM(wp, lp) (ATOM)HIWORD(lp)
  144. #define MPostWM_DDE_DATA(hTo, hFrom, hData, aItem) \
  145. PostMessage(hTo, WM_DDE_DATA, (WPARAM)hFrom, MAKELONG(hData, aItem))
  146. #define GET_WM_DDE_EXECUTE_HDATA(wp, lp) (HANDLE)HIWORD(lp)
  147. #define MPostWM_DDE_EXECUTE(hTo, hFrom, hDataExec) \
  148. PostMessage(hTo, WM_DDE_EXECUTE, (WPARAM)hFrom, MAKELONG(0, hDataExec))
  149. #define GET_WM_DDE_POKE_HDATA(wp, lp) (HANDLE)LOWORD(lp)
  150. #define GET_WM_DDE_POKE_ITEM(wp, lp) (ATOM)HIWORD(lp)
  151. #define MPostWM_DDE_POKE(hTo, hFrom, hData, aItem) \
  152. PostMessage(hTo, WM_DDE_POKE, (WPARAM)hFrom, MAKELONG(hData, aItem))
  153. #define GET_WM_DDE_EXECACK_STATUS(wp, lp) (WORD)LOWORD(lp)
  154. #define GET_WM_DDE_EXECACK_HDATA(wp, lp) (HANDLE)HIWORD(lp)
  155. #define MPostWM_DDE_EXECACK(hTo, hFrom, hCommands, wStatus) \
  156. PostMessage(hTo, WM_DDE_ACK, (WPARAM)hFrom, MAKELONG(wStatus, hCommands))
  157. #define GET_WM_DDE_REQUEST_FORMAT(wp, lp) (ATOM)LOWORD(lp)
  158. #define GET_WM_DDE_REQUEST_ITEM(wp, lp) (ATOM)HIWORD(lp)
  159. #define MPostWM_DDE_REQUEST(hTo, hFrom, fmt, aItem) \
  160. PostMessage(hTo, WM_DDE_REQUEST, (WPARAM)hFrom, MAKELONG(fmt, aItem))
  161. #define GET_WM_DDE_UNADVISE_FORMAT(wp, lp) (ATOM)LOWORD(lp)
  162. #define GET_WM_DDE_UNADVISE_ITEM(wp, lp) (ATOM)HIWORD(lp)
  163. #define MPostWM_DDE_UNADVISE(hTo, hFrom, fmt, aItem) \
  164. PostMessage(hTo, WM_DDE_UNADVISE, (WPARAM)hFrom, MAKELONG(fmt, aItem))
  165. #define MPostWM_DDE_TERMINATE(hTo, hFrom) \
  166. PostMessage(hTo, WM_DDE_TERMINATE, (WPARAM)hFrom, 0)
  167. /*-----------------------------------GDI-------------------------------------*/
  168. BOOL FAR PASCAL MGetAspectRatioFilter(HDC hdc, INT FAR * pcx, INT FAR * pcy);
  169. BOOL FAR PASCAL MGetBitmapDimension(HANDLE hBitmap, INT FAR * pcx, INT FAR * pcy);
  170. BOOL FAR PASCAL MGetBrushOrg(HDC hdc, INT FAR * px, INT FAR * py);
  171. BOOL FAR PASCAL MGetCurrentPosition(HDC hdc, INT FAR * px, INT FAR * py);
  172. BOOL FAR PASCAL MGetTextExtent(HDC hdc, LPSTR lpstr, INT cnt, INT FAR * pcx, INT FAR * pcy);
  173. BOOL FAR PASCAL MGetViewportExt(HDC hdc, INT FAR * pcx, INT FAR * pcy);
  174. BOOL FAR PASCAL MGetViewportOrg(HDC hdc, INT FAR * px, INT FAR * py);
  175. BOOL FAR PASCAL MGetWindowExt(HDC hdc, INT FAR * pcx, INT FAR * pcy);
  176. BOOL FAR PASCAL MGetWindowOrg(HDC hdc, INT FAR * px, INT FAR * py);
  177. #define MCreateDiscardableBitmap CreateDiscardableBitmap
  178. #define MMoveTo (VOID)MoveTo
  179. #define MOffsetViewportOrg (VOID)OffsetViewportOrg
  180. #define MOffsetWindowOrg (VOID)OffsetWindowOrg
  181. #define MScaleViewportExt (VOID)ScaleViewportExt
  182. #define MScaleWindowExt (VOID)ScaleWindowExt
  183. #define MSetBitmapDimension (VOID)SetBitmapDimension
  184. #define MSetBrushOrg (VOID)SetBrushOrg
  185. #define MSetViewportExt (VOID)SetViewportExt
  186. #define MSetViewportOrg (VOID)SetViewportOrg
  187. #define MSetWindowExt (VOID)SetWindowExt
  188. #define MSetWindowOrg (VOID)SetWindowOrg
  189. #define MUnrealizeObject UnrealizeObject
  190. /*-------------------------------------DEV-----------------------------------*/
  191. DWORD FAR PASCAL MDeviceCapabilities(LPSTR lpDriverName,
  192. LPSTR lpDeviceName, LPSTR lpPort, WORD2DWORD nIndex, LPSTR lpOutput,
  193. LPDEVMODE lpDevMode);
  194. BOOL FAR PASCAL MDeviceMode(HWND hWnd, LPSTR lpDriverName,
  195. LPSTR lpDeviceName, LPSTR lpOutput);
  196. WORD2DWORD FAR PASCAL MExtDeviceMode(HWND hWnd,LPSTR lpDriverName,
  197. LPDEVMODE lpDevModeOutput, LPSTR lpDeviceName, LPSTR lpPort,
  198. LPDEVMODE lpDevModeInput, LPSTR lpProfile, WORD2DWORD flMode);
  199. /*-----------------------------------KERNEL----------------------------------*/
  200. HANDLE FAR PASCAL MLoadLibrary(LPSTR lpszFilename);
  201. BOOL FAR PASCAL MDeleteFile(LPSTR lpPathName);
  202. #define DLLMEM_MOVEABLE LMEM_MOVEABLE
  203. #define DLLMEM_ZEROINIT LMEM_ZEROINIT
  204. #define GETMAJORVERSION(x) LOBYTE(x)
  205. #define GETMINORVERSION(x) HIBYTE(x)
  206. #define MCATCHBUF CATCHBUF
  207. #define LPMCATCHBUF LPCATCHBUF
  208. /* FUNCTION MAPPINGS */
  209. #define MLocalInit LocalInit
  210. #define MLockData(dummy) LockData(dummy)
  211. #define MUnlockData(dummy) UnlockData(dummy)
  212. #define MDllSharedAlloc LocalAlloc
  213. #define MDllSharedFlags LocalFlags
  214. #define MDllSharedFree LocalFree
  215. #define MDllSharedHandle LocalHandle
  216. #define MDllSharedLock LocalLock
  217. #define MDllSharedRealloc LocalReAlloc
  218. #define MDllSharedSize LocalSize
  219. #define MDllSharedUnlock LocalUnlock
  220. #define MFreeDOSEnvironment(p) TRUE
  221. #define MGetCurrentTask GetCurrentTask
  222. #define MGetDOSEnvironment GetDOSEnvironment
  223. #define MGetDriveType GetDriveType
  224. #define MGetModuleUsage GetModuleUsage
  225. #define MGetTempDrive GetTempDrive
  226. #define MGetTempFileName GetTempFileName
  227. #define MGetWinFlags GetWinFlags
  228. #define MOpenComm (HFILE)OpenComm
  229. #define MSetCommState(fh, lpDCB) SetCommState(lpDCB)
  230. #define MReadComm ReadComm
  231. #define MWriteComm WriteComm
  232. #define MCloseComm CloseComm
  233. #define MOpenFile (HFILE)OpenFile
  234. #define MThrow Throw
  235. #define MCatch Catch
  236. #define M_lclose _lclose
  237. #define M_lcreat (HFILE)_lcreat
  238. #define M_llseek _llseek
  239. #define M_lopen (HFILE)_lopen
  240. #define M_lread _lread
  241. #define M_lwrite _lwrite
  242. #define MGetMetaFileBits GetMetaFileBits
  243. #define MSetMetaFileBits SetMetaFileBits