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.

293 lines
14 KiB

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