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.

1371 lines
73 KiB

  1. /*****************************************************************************\
  2. * *
  3. * windowsx.h - Macro APIs, window message crackers, and control APIs *
  4. * *
  5. * Version Win32 / Windows NT *
  6. * *
  7. * Copyright (c) 1992-1999, Microsoft Corp. All rights reserved.*
  8. * *
  9. \*****************************************************************************/
  10. #ifndef _INC_WINDOWSX
  11. #define _INC_WINDOWSX
  12. #if (_MSC_VER >= 1020)
  13. #pragma once
  14. #endif
  15. #ifdef __cplusplus
  16. extern "C" { /* Assume C declarations for C++ */
  17. #endif /* __cplusplus */
  18. #ifndef SNDMSG
  19. #ifdef __cplusplus
  20. #ifndef _MAC
  21. #define SNDMSG ::SendMessage
  22. #else
  23. #define SNDMSG ::AfxSendMessage
  24. #endif
  25. #else /* __cplusplus */
  26. #ifndef _MAC
  27. #define SNDMSG SendMessage
  28. #else
  29. #define SNDMSG AfxSendMessage
  30. #endif
  31. #endif /* __cplusplus */
  32. #endif /* SNDMSG */
  33. /****** KERNEL Macro APIs ****************************************************/
  34. #define GetInstanceModule(hInstance) (HMODULE)(hInstance)
  35. #define GlobalPtrHandle(lp) \
  36. ((HGLOBAL)GlobalHandle(lp))
  37. #define GlobalLockPtr(lp) \
  38. ((BOOL)GlobalLock(GlobalPtrHandle(lp)))
  39. #define GlobalUnlockPtr(lp) \
  40. GlobalUnlock(GlobalPtrHandle(lp))
  41. #ifndef _MAC
  42. #define GlobalAllocPtr(flags, cb) \
  43. (GlobalLock(GlobalAlloc((flags), (cb))))
  44. #else
  45. #define GlobalAllocPtr(flags, cb) \
  46. (GlobalLock(GlobalAlloc((flags) | GMEM_PMODELOCKSTRATEGY, (cb))))
  47. #endif
  48. #define GlobalReAllocPtr(lp, cbNew, flags) \
  49. (GlobalUnlockPtr(lp), GlobalLock(GlobalReAlloc(GlobalPtrHandle(lp) , (cbNew), (flags))))
  50. #define GlobalFreePtr(lp) \
  51. (GlobalUnlockPtr(lp), (BOOL)(ULONG_PTR)GlobalFree(GlobalPtrHandle(lp)))
  52. /****** GDI Macro APIs *******************************************************/
  53. #define DeletePen(hpen) DeleteObject((HGDIOBJ)(HPEN)(hpen))
  54. #define SelectPen(hdc, hpen) ((HPEN)SelectObject((hdc), (HGDIOBJ)(HPEN)(hpen)))
  55. #define GetStockPen(i) ((HPEN)GetStockObject(i))
  56. #define DeleteBrush(hbr) DeleteObject((HGDIOBJ)(HBRUSH)(hbr))
  57. #define SelectBrush(hdc, hbr) ((HBRUSH)SelectObject((hdc), (HGDIOBJ)(HBRUSH)(hbr)))
  58. #define GetStockBrush(i) ((HBRUSH)GetStockObject(i))
  59. #define DeleteRgn(hrgn) DeleteObject((HGDIOBJ)(HRGN)(hrgn))
  60. #ifndef _MAC
  61. #define CopyRgn(hrgnDst, hrgnSrc) CombineRgn(hrgnDst, hrgnSrc, 0, RGN_COPY)
  62. #else
  63. #define AfxCopyRgn(hrgnDst, hrgnSrc) CombineRgn(hrgnDst, hrgnSrc, 0, RGN_COPY)
  64. #endif
  65. #define IntersectRgn(hrgnResult, hrgnA, hrgnB) CombineRgn(hrgnResult, hrgnA, hrgnB, RGN_AND)
  66. #define SubtractRgn(hrgnResult, hrgnA, hrgnB) CombineRgn(hrgnResult, hrgnA, hrgnB, RGN_DIFF)
  67. #ifndef _MAC
  68. #define UnionRgn(hrgnResult, hrgnA, hrgnB) CombineRgn(hrgnResult, hrgnA, hrgnB, RGN_OR)
  69. #define XorRgn(hrgnResult, hrgnA, hrgnB) CombineRgn(hrgnResult, hrgnA, hrgnB, RGN_XOR)
  70. #else
  71. #define AfxUnionRgn(hrgnResult, hrgnA, hrgnB) CombineRgn(hrgnResult, hrgnA, hrgnB, RGN_OR)
  72. #define AfxXorRgn(hrgnResult, hrgnA, hrgnB) CombineRgn(hrgnResult, hrgnA, hrgnB, RGN_XOR)
  73. #endif
  74. #define DeletePalette(hpal) DeleteObject((HGDIOBJ)(HPALETTE)(hpal))
  75. #define DeleteFont(hfont) DeleteObject((HGDIOBJ)(HFONT)(hfont))
  76. #define SelectFont(hdc, hfont) ((HFONT)SelectObject((hdc), (HGDIOBJ)(HFONT)(hfont)))
  77. #define GetStockFont(i) ((HFONT)GetStockObject(i))
  78. #define DeleteBitmap(hbm) DeleteObject((HGDIOBJ)(HBITMAP)(hbm))
  79. #define SelectBitmap(hdc, hbm) ((HBITMAP)SelectObject((hdc), (HGDIOBJ)(HBITMAP)(hbm)))
  80. #ifndef _MAC
  81. #define InsetRect(lprc, dx, dy) InflateRect((lprc), -(dx), -(dy))
  82. #else
  83. #define AfxInsetRect(lprc, dx, dy) InflateRect((lprc), -(dx), -(dy))
  84. #endif
  85. /****** USER Macro APIs ******************************************************/
  86. #define GetWindowInstance(hwnd) ((HMODULE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE))
  87. #define GetWindowStyle(hwnd) ((DWORD)GetWindowLong(hwnd, GWL_STYLE))
  88. #define GetWindowExStyle(hwnd) ((DWORD)GetWindowLong(hwnd, GWL_EXSTYLE))
  89. #define GetWindowOwner(hwnd) GetWindow(hwnd, GW_OWNER)
  90. #define GetFirstChild(hwnd) GetTopWindow(hwnd)
  91. #define GetFirstSibling(hwnd) GetWindow(hwnd, GW_HWNDFIRST)
  92. #define GetLastSibling(hwnd) GetWindow(hwnd, GW_HWNDLAST)
  93. #define GetNextSibling(hwnd) GetWindow(hwnd, GW_HWNDNEXT)
  94. #define GetPrevSibling(hwnd) GetWindow(hwnd, GW_HWNDPREV)
  95. #define GetWindowID(hwnd) GetDlgCtrlID(hwnd)
  96. #define SetWindowRedraw(hwnd, fRedraw) \
  97. ((void)SNDMSG(hwnd, WM_SETREDRAW, (WPARAM)(BOOL)(fRedraw), 0L))
  98. #define SubclassWindow(hwnd, lpfn) \
  99. ((WNDPROC)SetWindowLongPtr((hwnd), GWLP_WNDPROC, (LPARAM)(WNDPROC)(lpfn)))
  100. #define IsMinimized(hwnd) IsIconic(hwnd)
  101. #define IsMaximized(hwnd) IsZoomed(hwnd)
  102. #define IsRestored(hwnd) ((GetWindowStyle(hwnd) & (WS_MINIMIZE | WS_MAXIMIZE)) == 0L)
  103. #define SetWindowFont(hwnd, hfont, fRedraw) FORWARD_WM_SETFONT((hwnd), (hfont), (fRedraw), SNDMSG)
  104. #define GetWindowFont(hwnd) FORWARD_WM_GETFONT((hwnd), SNDMSG)
  105. #if (WINVER >= 0x030a)
  106. #ifdef UNIX
  107. #define MapWindowRect MwMapWindowRect
  108. LONG MwMapWindowRect(HWND, HWND, RECT *);
  109. #else
  110. #define MapWindowRect(hwndFrom, hwndTo, lprc) \
  111. MapWindowPoints((hwndFrom), (hwndTo), (POINT *)(lprc), 2)
  112. #endif /* !UNIX */
  113. #endif
  114. #define IsLButtonDown() (GetKeyState(VK_LBUTTON) < 0)
  115. #define IsRButtonDown() (GetKeyState(VK_RBUTTON) < 0)
  116. #define IsMButtonDown() (GetKeyState(VK_MBUTTON) < 0)
  117. #define SubclassDialog(hwndDlg, lpfn) \
  118. (SetWindowLongPtr(hwndDlg, DWLP_DLGPROC, (LPARAM)(lpfn)))
  119. #define SetDlgMsgResult(hwnd, msg, result) (( \
  120. (msg) == WM_CTLCOLORMSGBOX || \
  121. (msg) == WM_CTLCOLOREDIT || \
  122. (msg) == WM_CTLCOLORLISTBOX || \
  123. (msg) == WM_CTLCOLORBTN || \
  124. (msg) == WM_CTLCOLORDLG || \
  125. (msg) == WM_CTLCOLORSCROLLBAR || \
  126. (msg) == WM_CTLCOLORSTATIC || \
  127. (msg) == WM_COMPAREITEM || \
  128. (msg) == WM_VKEYTOITEM || \
  129. (msg) == WM_CHARTOITEM || \
  130. (msg) == WM_QUERYDRAGICON || \
  131. (msg) == WM_INITDIALOG \
  132. ) ? (BOOL)(result) : (SetWindowLongPtr((hwnd), DWLP_MSGRESULT, (LPARAM)(LRESULT)(result)), TRUE))
  133. #define DefDlgProcEx(hwnd, msg, wParam, lParam, pfRecursion) \
  134. (*(pfRecursion) = TRUE, DefDlgProc(hwnd, msg, wParam, lParam))
  135. #define CheckDefDlgRecursion(pfRecursion) \
  136. if (*(pfRecursion)) { *(pfRecursion) = FALSE; return FALSE; }
  137. /****** Message crackers ****************************************************/
  138. #define HANDLE_MSG(hwnd, message, fn) \
  139. case (message): return HANDLE_##message((hwnd), (wParam), (lParam), (fn))
  140. /* void Cls_OnCompacting(HWND hwnd, UINT compactRatio) */
  141. #define HANDLE_WM_COMPACTING(hwnd, wParam, lParam, fn) \
  142. ((fn)((hwnd), (UINT)(wParam)), 0L)
  143. #define FORWARD_WM_COMPACTING(hwnd, compactRatio, fn) \
  144. (void)(fn)((hwnd), WM_COMPACTING, (WPARAM)(UINT)(compactRatio), 0L)
  145. /* void Cls_OnWinIniChange(HWND hwnd, LPCTSTR lpszSectionName) */
  146. #define HANDLE_WM_WININICHANGE(hwnd, wParam, lParam, fn) \
  147. ((fn)((hwnd), (LPCTSTR)(lParam)), 0L)
  148. #define FORWARD_WM_WININICHANGE(hwnd, lpszSectionName, fn) \
  149. (void)(fn)((hwnd), WM_WININICHANGE, 0L, (LPARAM)(LPCTSTR)(lpszSectionName))
  150. /* void Cls_OnSysColorChange(HWND hwnd) */
  151. #define HANDLE_WM_SYSCOLORCHANGE(hwnd, wParam, lParam, fn) \
  152. ((fn)(hwnd), 0L)
  153. #define FORWARD_WM_SYSCOLORCHANGE(hwnd, fn) \
  154. (void)(fn)((hwnd), WM_SYSCOLORCHANGE, 0L, 0L)
  155. /* BOOL Cls_OnQueryNewPalette(HWND hwnd) */
  156. #define HANDLE_WM_QUERYNEWPALETTE(hwnd, wParam, lParam, fn) \
  157. MAKELRESULT((BOOL)(fn)(hwnd), 0L)
  158. #define FORWARD_WM_QUERYNEWPALETTE(hwnd, fn) \
  159. (BOOL)(DWORD)(fn)((hwnd), WM_QUERYNEWPALETTE, 0L, 0L)
  160. /* void Cls_OnPaletteIsChanging(HWND hwnd, HWND hwndPaletteChange) */
  161. #define HANDLE_WM_PALETTEISCHANGING(hwnd, wParam, lParam, fn) \
  162. ((fn)((hwnd), (HWND)(wParam)), 0L)
  163. #define FORWARD_WM_PALETTEISCHANGING(hwnd, hwndPaletteChange, fn) \
  164. (void)(fn)((hwnd), WM_PALETTEISCHANGING, (WPARAM)(HWND)(hwndPaletteChange), 0L)
  165. /* void Cls_OnPaletteChanged(HWND hwnd, HWND hwndPaletteChange) */
  166. #define HANDLE_WM_PALETTECHANGED(hwnd, wParam, lParam, fn) \
  167. ((fn)((hwnd), (HWND)(wParam)), 0L)
  168. #define FORWARD_WM_PALETTECHANGED(hwnd, hwndPaletteChange, fn) \
  169. (void)(fn)((hwnd), WM_PALETTECHANGED, (WPARAM)(HWND)(hwndPaletteChange), 0L)
  170. /* void Cls_OnFontChange(HWND hwnd) */
  171. #define HANDLE_WM_FONTCHANGE(hwnd, wParam, lParam, fn) \
  172. ((fn)(hwnd), 0L)
  173. #define FORWARD_WM_FONTCHANGE(hwnd, fn) \
  174. (void)(fn)((hwnd), WM_FONTCHANGE, 0L, 0L)
  175. /* void Cls_OnSpoolerStatus(HWND hwnd, UINT status, int cJobInQueue) */
  176. #define HANDLE_WM_SPOOLERSTATUS(hwnd, wParam, lParam, fn) \
  177. ((fn)((hwnd), (UINT)(wParam), (int)(short)LOWORD(lParam)), 0L)
  178. #define FORWARD_WM_SPOOLERSTATUS(hwnd, status, cJobInQueue, fn) \
  179. (void)(fn)((hwnd), WM_SPOOLERSTATUS, (WPARAM)(status), MAKELPARAM((cJobInQueue), 0))
  180. /* void Cls_OnDevModeChange(HWND hwnd, LPCTSTR lpszDeviceName) */
  181. #define HANDLE_WM_DEVMODECHANGE(hwnd, wParam, lParam, fn) \
  182. ((fn)((hwnd), (LPCTSTR)(lParam)), 0L)
  183. #define FORWARD_WM_DEVMODECHANGE(hwnd, lpszDeviceName, fn) \
  184. (void)(fn)((hwnd), WM_DEVMODECHANGE, 0L, (LPARAM)(LPCTSTR)(lpszDeviceName))
  185. /* void Cls_OnTimeChange(HWND hwnd) */
  186. #define HANDLE_WM_TIMECHANGE(hwnd, wParam, lParam, fn) \
  187. ((fn)(hwnd), 0L)
  188. #define FORWARD_WM_TIMECHANGE(hwnd, fn) \
  189. (void)(fn)((hwnd), WM_TIMECHANGE, 0L, 0L)
  190. /* void Cls_OnPower(HWND hwnd, int code) */
  191. #define HANDLE_WM_POWER(hwnd, wParam, lParam, fn) \
  192. ((fn)((hwnd), (int)(wParam)), 0L)
  193. #define FORWARD_WM_POWER(hwnd, code, fn) \
  194. (void)(fn)((hwnd), WM_POWER, (WPARAM)(int)(code), 0L)
  195. /* BOOL Cls_OnQueryEndSession(HWND hwnd) */
  196. #define HANDLE_WM_QUERYENDSESSION(hwnd, wParam, lParam, fn) \
  197. MAKELRESULT((BOOL)(fn)(hwnd), 0L)
  198. #define FORWARD_WM_QUERYENDSESSION(hwnd, fn) \
  199. (BOOL)(DWORD)(fn)((hwnd), WM_QUERYENDSESSION, 0L, 0L)
  200. /* void Cls_OnEndSession(HWND hwnd, BOOL fEnding) */
  201. #define HANDLE_WM_ENDSESSION(hwnd, wParam, lParam, fn) \
  202. ((fn)((hwnd), (BOOL)(wParam)), 0L)
  203. #define FORWARD_WM_ENDSESSION(hwnd, fEnding, fn) \
  204. (void)(fn)((hwnd), WM_ENDSESSION, (WPARAM)(BOOL)(fEnding), 0L)
  205. /* void Cls_OnQuit(HWND hwnd, int exitCode) */
  206. #define HANDLE_WM_QUIT(hwnd, wParam, lParam, fn) \
  207. ((fn)((hwnd), (int)(wParam)), 0L)
  208. #define FORWARD_WM_QUIT(hwnd, exitCode, fn) \
  209. (void)(fn)((hwnd), WM_QUIT, (WPARAM)(exitCode), 0L)
  210. /* This message is in Windows 3.1 only */
  211. /* void Cls_OnSystemError(HWND hwnd, int errCode) */
  212. #define HANDLE_WM_SYSTEMERROR(hwnd, wParam, lParam, fn) 0L
  213. #define FORWARD_WM_SYSTEMERROR(hwnd, errCode, fn) 0L
  214. /* BOOL Cls_OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct) */
  215. #define HANDLE_WM_CREATE(hwnd, wParam, lParam, fn) \
  216. ((fn)((hwnd), (LPCREATESTRUCT)(lParam)) ? 0L : (LRESULT)-1L)
  217. #define FORWARD_WM_CREATE(hwnd, lpCreateStruct, fn) \
  218. (BOOL)(DWORD)(fn)((hwnd), WM_CREATE, 0L, (LPARAM)(LPCREATESTRUCT)(lpCreateStruct))
  219. /* BOOL Cls_OnNCCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct) */
  220. #define HANDLE_WM_NCCREATE(hwnd, wParam, lParam, fn) \
  221. (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (LPCREATESTRUCT)(lParam))
  222. #define FORWARD_WM_NCCREATE(hwnd, lpCreateStruct, fn) \
  223. (BOOL)(DWORD)(fn)((hwnd), WM_NCCREATE, 0L, (LPARAM)(LPCREATESTRUCT)(lpCreateStruct))
  224. /* void Cls_OnDestroy(HWND hwnd) */
  225. #define HANDLE_WM_DESTROY(hwnd, wParam, lParam, fn) \
  226. ((fn)(hwnd), 0L)
  227. #define FORWARD_WM_DESTROY(hwnd, fn) \
  228. (void)(fn)((hwnd), WM_DESTROY, 0L, 0L)
  229. /* void Cls_OnNCDestroy(HWND hwnd) */
  230. #define HANDLE_WM_NCDESTROY(hwnd, wParam, lParam, fn) \
  231. ((fn)(hwnd), 0L)
  232. #define FORWARD_WM_NCDESTROY(hwnd, fn) \
  233. (void)(fn)((hwnd), WM_NCDESTROY, 0L, 0L)
  234. /* void Cls_OnShowWindow(HWND hwnd, BOOL fShow, UINT status) */
  235. #define HANDLE_WM_SHOWWINDOW(hwnd, wParam, lParam, fn) \
  236. ((fn)((hwnd), (BOOL)(wParam), (UINT)(lParam)), 0L)
  237. #define FORWARD_WM_SHOWWINDOW(hwnd, fShow, status, fn) \
  238. (void)(fn)((hwnd), WM_SHOWWINDOW, (WPARAM)(BOOL)(fShow), (LPARAM)(UINT)(status))
  239. /* void Cls_OnSetRedraw(HWND hwnd, BOOL fRedraw) */
  240. #define HANDLE_WM_SETREDRAW(hwnd, wParam, lParam, fn) \
  241. ((fn)((hwnd), (BOOL)(wParam)), 0L)
  242. #define FORWARD_WM_SETREDRAW(hwnd, fRedraw, fn) \
  243. (void)(fn)((hwnd), WM_SETREDRAW, (WPARAM)(BOOL)(fRedraw), 0L)
  244. /* void Cls_OnEnable(HWND hwnd, BOOL fEnable) */
  245. #define HANDLE_WM_ENABLE(hwnd, wParam, lParam, fn) \
  246. ((fn)((hwnd), (BOOL)(wParam)), 0L)
  247. #define FORWARD_WM_ENABLE(hwnd, fEnable, fn) \
  248. (void)(fn)((hwnd), WM_ENABLE, (WPARAM)(BOOL)(fEnable), 0L)
  249. /* void Cls_OnSetText(HWND hwnd, LPCTSTR lpszText) */
  250. #define HANDLE_WM_SETTEXT(hwnd, wParam, lParam, fn) \
  251. ((fn)((hwnd), (LPCTSTR)(lParam)), 0L)
  252. #define FORWARD_WM_SETTEXT(hwnd, lpszText, fn) \
  253. (void)(fn)((hwnd), WM_SETTEXT, 0L, (LPARAM)(LPCTSTR)(lpszText))
  254. /* INT Cls_OnGetText(HWND hwnd, int cchTextMax, LPTSTR lpszText) */
  255. #define HANDLE_WM_GETTEXT(hwnd, wParam, lParam, fn) \
  256. (LRESULT)(DWORD)(int)(fn)((hwnd), (int)(wParam), (LPTSTR)(lParam))
  257. #define FORWARD_WM_GETTEXT(hwnd, cchTextMax, lpszText, fn) \
  258. (int)(DWORD)(fn)((hwnd), WM_GETTEXT, (WPARAM)(int)(cchTextMax), (LPARAM)(LPTSTR)(lpszText))
  259. /* INT Cls_OnGetTextLength(HWND hwnd) */
  260. #define HANDLE_WM_GETTEXTLENGTH(hwnd, wParam, lParam, fn) \
  261. (LRESULT)(DWORD)(int)(fn)(hwnd)
  262. #define FORWARD_WM_GETTEXTLENGTH(hwnd, fn) \
  263. (int)(DWORD)(fn)((hwnd), WM_GETTEXTLENGTH, 0L, 0L)
  264. /* BOOL Cls_OnWindowPosChanging(HWND hwnd, LPWINDOWPOS lpwpos) */
  265. #define HANDLE_WM_WINDOWPOSCHANGING(hwnd, wParam, lParam, fn) \
  266. (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (LPWINDOWPOS)(lParam))
  267. #define FORWARD_WM_WINDOWPOSCHANGING(hwnd, lpwpos, fn) \
  268. (BOOL)(DWORD)(fn)((hwnd), WM_WINDOWPOSCHANGING, 0L, (LPARAM)(LPWINDOWPOS)(lpwpos))
  269. /* void Cls_OnWindowPosChanged(HWND hwnd, const LPWINDOWPOS lpwpos) */
  270. #define HANDLE_WM_WINDOWPOSCHANGED(hwnd, wParam, lParam, fn) \
  271. ((fn)((hwnd), (const LPWINDOWPOS)(lParam)), 0L)
  272. #define FORWARD_WM_WINDOWPOSCHANGED(hwnd, lpwpos, fn) \
  273. (void)(fn)((hwnd), WM_WINDOWPOSCHANGED, 0L, (LPARAM)(const LPWINDOWPOS)(lpwpos))
  274. /* void Cls_OnMove(HWND hwnd, int x, int y) */
  275. #define HANDLE_WM_MOVE(hwnd, wParam, lParam, fn) \
  276. ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)), 0L)
  277. #define FORWARD_WM_MOVE(hwnd, x, y, fn) \
  278. (void)(fn)((hwnd), WM_MOVE, 0L, MAKELPARAM((x), (y)))
  279. /* void Cls_OnSize(HWND hwnd, UINT state, int cx, int cy) */
  280. #define HANDLE_WM_SIZE(hwnd, wParam, lParam, fn) \
  281. ((fn)((hwnd), (UINT)(wParam), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)), 0L)
  282. #define FORWARD_WM_SIZE(hwnd, state, cx, cy, fn) \
  283. (void)(fn)((hwnd), WM_SIZE, (WPARAM)(UINT)(state), MAKELPARAM((cx), (cy)))
  284. /* void Cls_OnClose(HWND hwnd) */
  285. #define HANDLE_WM_CLOSE(hwnd, wParam, lParam, fn) \
  286. ((fn)(hwnd), 0L)
  287. #define FORWARD_WM_CLOSE(hwnd, fn) \
  288. (void)(fn)((hwnd), WM_CLOSE, 0L, 0L)
  289. /* BOOL Cls_OnQueryOpen(HWND hwnd) */
  290. #define HANDLE_WM_QUERYOPEN(hwnd, wParam, lParam, fn) \
  291. MAKELRESULT((BOOL)(fn)(hwnd), 0L)
  292. #define FORWARD_WM_QUERYOPEN(hwnd, fn) \
  293. (BOOL)(DWORD)(fn)((hwnd), WM_QUERYOPEN, 0L, 0L)
  294. /* void Cls_OnGetMinMaxInfo(HWND hwnd, LPMINMAXINFO lpMinMaxInfo) */
  295. #define HANDLE_WM_GETMINMAXINFO(hwnd, wParam, lParam, fn) \
  296. ((fn)((hwnd), (LPMINMAXINFO)(lParam)), 0L)
  297. #define FORWARD_WM_GETMINMAXINFO(hwnd, lpMinMaxInfo, fn) \
  298. (void)(fn)((hwnd), WM_GETMINMAXINFO, 0L, (LPARAM)(LPMINMAXINFO)(lpMinMaxInfo))
  299. /* void Cls_OnPaint(HWND hwnd) */
  300. #define HANDLE_WM_PAINT(hwnd, wParam, lParam, fn) \
  301. ((fn)(hwnd), 0L)
  302. #define FORWARD_WM_PAINT(hwnd, fn) \
  303. (void)(fn)((hwnd), WM_PAINT, 0L, 0L)
  304. /* BOOL Cls_OnEraseBkgnd(HWND hwnd, HDC hdc) */
  305. #define HANDLE_WM_ERASEBKGND(hwnd, wParam, lParam, fn) \
  306. (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (HDC)(wParam))
  307. #define FORWARD_WM_ERASEBKGND(hwnd, hdc, fn) \
  308. (BOOL)(DWORD)(fn)((hwnd), WM_ERASEBKGND, (WPARAM)(HDC)(hdc), 0L)
  309. /* BOOL Cls_OnIconEraseBkgnd(HWND hwnd, HDC hdc) */
  310. #define HANDLE_WM_ICONERASEBKGND(hwnd, wParam, lParam, fn) \
  311. (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (HDC)(wParam))
  312. #define FORWARD_WM_ICONERASEBKGND(hwnd, hdc, fn) \
  313. (BOOL)(DWORD)(fn)((hwnd), WM_ICONERASEBKGND, (WPARAM)(HDC)(hdc), 0L)
  314. /* void Cls_OnNCPaint(HWND hwnd, HRGN hrgn) */
  315. #define HANDLE_WM_NCPAINT(hwnd, wParam, lParam, fn) \
  316. ((fn)((hwnd), (HRGN)(wParam)), 0L)
  317. #define FORWARD_WM_NCPAINT(hwnd, hrgn, fn) \
  318. (void)(fn)((hwnd), WM_NCPAINT, (WPARAM)(HRGN)(hrgn), 0L)
  319. /* UINT Cls_OnNCCalcSize(HWND hwnd, BOOL fCalcValidRects, NCCALCSIZE_PARAMS * lpcsp) */
  320. #define HANDLE_WM_NCCALCSIZE(hwnd, wParam, lParam, fn) \
  321. (LRESULT)(DWORD)(UINT)(fn)((hwnd), (BOOL)(wParam), (NCCALCSIZE_PARAMS *)(lParam))
  322. #define FORWARD_WM_NCCALCSIZE(hwnd, fCalcValidRects, lpcsp, fn) \
  323. (UINT)(DWORD)(fn)((hwnd), WM_NCCALCSIZE, (WPARAM)(fCalcValidRects), (LPARAM)(NCCALCSIZE_PARAMS *)(lpcsp))
  324. /* UINT Cls_OnNCHitTest(HWND hwnd, int x, int y) */
  325. #define HANDLE_WM_NCHITTEST(hwnd, wParam, lParam, fn) \
  326. (LRESULT)(DWORD)(UINT)(fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam))
  327. #define FORWARD_WM_NCHITTEST(hwnd, x, y, fn) \
  328. (UINT)(DWORD)(fn)((hwnd), WM_NCHITTEST, 0L, MAKELPARAM((x), (y)))
  329. /* HICON Cls_OnQueryDragIcon(HWND hwnd) */
  330. #define HANDLE_WM_QUERYDRAGICON(hwnd, wParam, lParam, fn) \
  331. (LRESULT)(DWORD)(UINT)(fn)(hwnd)
  332. #define FORWARD_WM_QUERYDRAGICON(hwnd, fn) \
  333. (HICON)(UINT)(DWORD)(fn)((hwnd), WM_QUERYDRAGICON, 0L, 0L)
  334. #ifdef _INC_SHELLAPI
  335. /* void Cls_OnDropFiles(HWND hwnd, HDROP hdrop) */
  336. #define HANDLE_WM_DROPFILES(hwnd, wParam, lParam, fn) \
  337. ((fn)((hwnd), (HDROP)(wParam)), 0L)
  338. #define FORWARD_WM_DROPFILES(hwnd, hdrop, fn) \
  339. (void)(fn)((hwnd), WM_DROPFILES, (WPARAM)(HDROP)(hdrop), 0L)
  340. #endif /* _INC_SHELLAPI */
  341. /* void Cls_OnActivate(HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized) */
  342. #define HANDLE_WM_ACTIVATE(hwnd, wParam, lParam, fn) \
  343. ((fn)((hwnd), (UINT)LOWORD(wParam), (HWND)(lParam), (BOOL)HIWORD(wParam)), 0L)
  344. #define FORWARD_WM_ACTIVATE(hwnd, state, hwndActDeact, fMinimized, fn) \
  345. (void)(fn)((hwnd), WM_ACTIVATE, MAKEWPARAM((state), (fMinimized)), (LPARAM)(HWND)(hwndActDeact))
  346. /* void Cls_OnActivateApp(HWND hwnd, BOOL fActivate, DWORD dwThreadId) */
  347. #define HANDLE_WM_ACTIVATEAPP(hwnd, wParam, lParam, fn) \
  348. ((fn)((hwnd), (BOOL)(wParam), (DWORD)(lParam)), 0L)
  349. #define FORWARD_WM_ACTIVATEAPP(hwnd, fActivate, dwThreadId, fn) \
  350. (void)(fn)((hwnd), WM_ACTIVATEAPP, (WPARAM)(BOOL)(fActivate), (LPARAM)(dwThreadId))
  351. /* BOOL Cls_OnNCActivate(HWND hwnd, BOOL fActive, HWND hwndActDeact, BOOL fMinimized) */
  352. #define HANDLE_WM_NCACTIVATE(hwnd, wParam, lParam, fn) \
  353. (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (BOOL)(wParam), 0L, 0L)
  354. #define FORWARD_WM_NCACTIVATE(hwnd, fActive, hwndActDeact, fMinimized, fn) \
  355. (BOOL)(DWORD)(fn)((hwnd), WM_NCACTIVATE, (WPARAM)(BOOL)(fActive), 0L)
  356. /* void Cls_OnSetFocus(HWND hwnd, HWND hwndOldFocus) */
  357. #define HANDLE_WM_SETFOCUS(hwnd, wParam, lParam, fn) \
  358. ((fn)((hwnd), (HWND)(wParam)), 0L)
  359. #define FORWARD_WM_SETFOCUS(hwnd, hwndOldFocus, fn) \
  360. (void)(fn)((hwnd), WM_SETFOCUS, (WPARAM)(HWND)(hwndOldFocus), 0L)
  361. /* void Cls_OnKillFocus(HWND hwnd, HWND hwndNewFocus) */
  362. #define HANDLE_WM_KILLFOCUS(hwnd, wParam, lParam, fn) \
  363. ((fn)((hwnd), (HWND)(wParam)), 0L)
  364. #define FORWARD_WM_KILLFOCUS(hwnd, hwndNewFocus, fn) \
  365. (void)(fn)((hwnd), WM_KILLFOCUS, (WPARAM)(HWND)(hwndNewFocus), 0L)
  366. /* void Cls_OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags) */
  367. #define HANDLE_WM_KEYDOWN(hwnd, wParam, lParam, fn) \
  368. ((fn)((hwnd), (UINT)(wParam), TRUE, (int)(short)LOWORD(lParam), (UINT)HIWORD(lParam)), 0L)
  369. #define FORWARD_WM_KEYDOWN(hwnd, vk, cRepeat, flags, fn) \
  370. (void)(fn)((hwnd), WM_KEYDOWN, (WPARAM)(UINT)(vk), MAKELPARAM((cRepeat), (flags)))
  371. /* void Cls_OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags) */
  372. #define HANDLE_WM_KEYUP(hwnd, wParam, lParam, fn) \
  373. ((fn)((hwnd), (UINT)(wParam), FALSE, (int)(short)LOWORD(lParam), (UINT)HIWORD(lParam)), 0L)
  374. #define FORWARD_WM_KEYUP(hwnd, vk, cRepeat, flags, fn) \
  375. (void)(fn)((hwnd), WM_KEYUP, (WPARAM)(UINT)(vk), MAKELPARAM((cRepeat), (flags)))
  376. /* void Cls_OnChar(HWND hwnd, TCHAR ch, int cRepeat) */
  377. #define HANDLE_WM_CHAR(hwnd, wParam, lParam, fn) \
  378. ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
  379. #define FORWARD_WM_CHAR(hwnd, ch, cRepeat, fn) \
  380. (void)(fn)((hwnd), WM_CHAR, (WPARAM)(TCHAR)(ch), MAKELPARAM((cRepeat),0))
  381. /* void Cls_OnDeadChar(HWND hwnd, TCHAR ch, int cRepeat) */
  382. #define HANDLE_WM_DEADCHAR(hwnd, wParam, lParam, fn) \
  383. ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
  384. #define FORWARD_WM_DEADCHAR(hwnd, ch, cRepeat, fn) \
  385. (void)(fn)((hwnd), WM_DEADCHAR, (WPARAM)(TCHAR)(ch), MAKELPARAM((cRepeat),0))
  386. /* void Cls_OnSysKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags) */
  387. #define HANDLE_WM_SYSKEYDOWN(hwnd, wParam, lParam, fn) \
  388. ((fn)((hwnd), (UINT)(wParam), TRUE, (int)(short)LOWORD(lParam), (UINT)HIWORD(lParam)), 0L)
  389. #define FORWARD_WM_SYSKEYDOWN(hwnd, vk, cRepeat, flags, fn) \
  390. (void)(fn)((hwnd), WM_SYSKEYDOWN, (WPARAM)(UINT)(vk), MAKELPARAM((cRepeat), (flags)))
  391. /* void Cls_OnSysKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags) */
  392. #define HANDLE_WM_SYSKEYUP(hwnd, wParam, lParam, fn) \
  393. ((fn)((hwnd), (UINT)(wParam), FALSE, (int)(short)LOWORD(lParam), (UINT)HIWORD(lParam)), 0L)
  394. #define FORWARD_WM_SYSKEYUP(hwnd, vk, cRepeat, flags, fn) \
  395. (void)(fn)((hwnd), WM_SYSKEYUP, (WPARAM)(UINT)(vk), MAKELPARAM((cRepeat), (flags)))
  396. /* void Cls_OnSysChar(HWND hwnd, TCHAR ch, int cRepeat) */
  397. #define HANDLE_WM_SYSCHAR(hwnd, wParam, lParam, fn) \
  398. ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
  399. #define FORWARD_WM_SYSCHAR(hwnd, ch, cRepeat, fn) \
  400. (void)(fn)((hwnd), WM_SYSCHAR, (WPARAM)(TCHAR)(ch), MAKELPARAM((cRepeat), 0))
  401. /* void Cls_OnSysDeadChar(HWND hwnd, TCHAR ch, int cRepeat) */
  402. #define HANDLE_WM_SYSDEADCHAR(hwnd, wParam, lParam, fn) \
  403. ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
  404. #define FORWARD_WM_SYSDEADCHAR(hwnd, ch, cRepeat, fn) \
  405. (void)(fn)((hwnd), WM_SYSDEADCHAR, (WPARAM)(TCHAR)(ch), MAKELPARAM((cRepeat), 0))
  406. /* void Cls_OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags) */
  407. #define HANDLE_WM_MOUSEMOVE(hwnd, wParam, lParam, fn) \
  408. ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  409. #define FORWARD_WM_MOUSEMOVE(hwnd, x, y, keyFlags, fn) \
  410. (void)(fn)((hwnd), WM_MOUSEMOVE, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
  411. /* void Cls_OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) */
  412. #define HANDLE_WM_LBUTTONDOWN(hwnd, wParam, lParam, fn) \
  413. ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  414. #define FORWARD_WM_LBUTTONDOWN(hwnd, fDoubleClick, x, y, keyFlags, fn) \
  415. (void)(fn)((hwnd), (fDoubleClick) ? WM_LBUTTONDBLCLK : WM_LBUTTONDOWN, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
  416. /* void Cls_OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) */
  417. #define HANDLE_WM_LBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
  418. ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  419. /* void Cls_OnLButtonUp(HWND hwnd, int x, int y, UINT keyFlags) */
  420. #define HANDLE_WM_LBUTTONUP(hwnd, wParam, lParam, fn) \
  421. ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  422. #define FORWARD_WM_LBUTTONUP(hwnd, x, y, keyFlags, fn) \
  423. (void)(fn)((hwnd), WM_LBUTTONUP, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
  424. /* void Cls_OnRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) */
  425. #define HANDLE_WM_RBUTTONDOWN(hwnd, wParam, lParam, fn) \
  426. ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  427. #define FORWARD_WM_RBUTTONDOWN(hwnd, fDoubleClick, x, y, keyFlags, fn) \
  428. (void)(fn)((hwnd), (fDoubleClick) ? WM_RBUTTONDBLCLK : WM_RBUTTONDOWN, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
  429. /* void Cls_OnRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) */
  430. #define HANDLE_WM_RBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
  431. ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  432. /* void Cls_OnRButtonUp(HWND hwnd, int x, int y, UINT flags) */
  433. #define HANDLE_WM_RBUTTONUP(hwnd, wParam, lParam, fn) \
  434. ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  435. #define FORWARD_WM_RBUTTONUP(hwnd, x, y, keyFlags, fn) \
  436. (void)(fn)((hwnd), WM_RBUTTONUP, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
  437. /* void Cls_OnMButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) */
  438. #define HANDLE_WM_MBUTTONDOWN(hwnd, wParam, lParam, fn) \
  439. ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  440. #define FORWARD_WM_MBUTTONDOWN(hwnd, fDoubleClick, x, y, keyFlags, fn) \
  441. (void)(fn)((hwnd), (fDoubleClick) ? WM_MBUTTONDBLCLK : WM_MBUTTONDOWN, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
  442. /* void Cls_OnMButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) */
  443. #define HANDLE_WM_MBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
  444. ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  445. /* void Cls_OnMButtonUp(HWND hwnd, int x, int y, UINT flags) */
  446. #define HANDLE_WM_MBUTTONUP(hwnd, wParam, lParam, fn) \
  447. ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  448. #define FORWARD_WM_MBUTTONUP(hwnd, x, y, keyFlags, fn) \
  449. (void)(fn)((hwnd), WM_MBUTTONUP, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
  450. /* void Cls_OnMouseWheel(HWND hwnd, int xPos, int yPos, int zDelta, UINT fwKeys) */
  451. #define HANDLE_WM_MOUSEWHEEL(hwnd, wParam, lParam, fn) \
  452. ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (int)(short)HIWORD(wParam), (UINT)(short)LOWORD(wParam)), 0L)
  453. #define FORWARD_WM_MOUSEWHEEL(hwnd, xPos, yPos, zDelta, fwKeys, fn) \
  454. (void)(fn)((hwnd), WM_MOUSEWHEEL, MAKEWPARAM((fwKeys),(zDelta)), MAKELPARAM((x),(y)))
  455. /* void Cls_OnNCMouseMove(HWND hwnd, int x, int y, UINT codeHitTest) */
  456. #define HANDLE_WM_NCMOUSEMOVE(hwnd, wParam, lParam, fn) \
  457. ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  458. #define FORWARD_WM_NCMOUSEMOVE(hwnd, x, y, codeHitTest, fn) \
  459. (void)(fn)((hwnd), WM_NCMOUSEMOVE, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)))
  460. /* void Cls_OnNCLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT codeHitTest) */
  461. #define HANDLE_WM_NCLBUTTONDOWN(hwnd, wParam, lParam, fn) \
  462. ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  463. #define FORWARD_WM_NCLBUTTONDOWN(hwnd, fDoubleClick, x, y, codeHitTest, fn) \
  464. (void)(fn)((hwnd), (fDoubleClick) ? WM_NCLBUTTONDBLCLK : WM_NCLBUTTONDOWN, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)))
  465. /* void Cls_OnNCLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT codeHitTest) */
  466. #define HANDLE_WM_NCLBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
  467. ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  468. /* void Cls_OnNCLButtonUp(HWND hwnd, int x, int y, UINT codeHitTest) */
  469. #define HANDLE_WM_NCLBUTTONUP(hwnd, wParam, lParam, fn) \
  470. ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  471. #define FORWARD_WM_NCLBUTTONUP(hwnd, x, y, codeHitTest, fn) \
  472. (void)(fn)((hwnd), WM_NCLBUTTONUP, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)))
  473. /* void Cls_OnNCRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT codeHitTest) */
  474. #define HANDLE_WM_NCRBUTTONDOWN(hwnd, wParam, lParam, fn) \
  475. ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  476. #define FORWARD_WM_NCRBUTTONDOWN(hwnd, fDoubleClick, x, y, codeHitTest, fn) \
  477. (void)(fn)((hwnd), (fDoubleClick) ? WM_NCRBUTTONDBLCLK : WM_NCRBUTTONDOWN, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)) )
  478. /* void Cls_OnNCRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT codeHitTest) */
  479. #define HANDLE_WM_NCRBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
  480. ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  481. /* void Cls_OnNCRButtonUp(HWND hwnd, int x, int y, UINT codeHitTest) */
  482. #define HANDLE_WM_NCRBUTTONUP(hwnd, wParam, lParam, fn) \
  483. ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  484. #define FORWARD_WM_NCRBUTTONUP(hwnd, x, y, codeHitTest, fn) \
  485. (void)(fn)((hwnd), WM_NCRBUTTONUP, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)) )
  486. /* void Cls_OnNCMButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT codeHitTest) */
  487. #define HANDLE_WM_NCMBUTTONDOWN(hwnd, wParam, lParam, fn) \
  488. ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  489. #define FORWARD_WM_NCMBUTTONDOWN(hwnd, fDoubleClick, x, y, codeHitTest, fn) \
  490. (void)(fn)((hwnd), (fDoubleClick) ? WM_NCMBUTTONDBLCLK : WM_NCMBUTTONDOWN, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)) )
  491. /* void Cls_OnNCMButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT codeHitTest) */
  492. #define HANDLE_WM_NCMBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
  493. ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  494. /* void Cls_OnNCMButtonUp(HWND hwnd, int x, int y, UINT codeHitTest) */
  495. #define HANDLE_WM_NCMBUTTONUP(hwnd, wParam, lParam, fn) \
  496. ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
  497. #define FORWARD_WM_NCMBUTTONUP(hwnd, x, y, codeHitTest, fn) \
  498. (void)(fn)((hwnd), WM_NCMBUTTONUP, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)) )
  499. /* int Cls_OnMouseActivate(HWND hwnd, HWND hwndTopLevel, UINT codeHitTest, UINT msg) */
  500. #define HANDLE_WM_MOUSEACTIVATE(hwnd, wParam, lParam, fn) \
  501. (LRESULT)(DWORD)(int)(fn)((hwnd), (HWND)(wParam), (UINT)LOWORD(lParam), (UINT)HIWORD(lParam))
  502. #define FORWARD_WM_MOUSEACTIVATE(hwnd, hwndTopLevel, codeHitTest, msg, fn) \
  503. (int)(DWORD)(fn)((hwnd), WM_MOUSEACTIVATE, (WPARAM)(HWND)(hwndTopLevel), MAKELPARAM((codeHitTest), (msg)))
  504. /* void Cls_OnCancelMode(HWND hwnd) */
  505. #define HANDLE_WM_CANCELMODE(hwnd, wParam, lParam, fn) \
  506. ((fn)(hwnd), 0L)
  507. #define FORWARD_WM_CANCELMODE(hwnd, fn) \
  508. (void)(fn)((hwnd), WM_CANCELMODE, 0L, 0L)
  509. /* void Cls_OnTimer(HWND hwnd, UINT id) */
  510. #define HANDLE_WM_TIMER(hwnd, wParam, lParam, fn) \
  511. ((fn)((hwnd), (UINT)(wParam)), 0L)
  512. #define FORWARD_WM_TIMER(hwnd, id, fn) \
  513. (void)(fn)((hwnd), WM_TIMER, (WPARAM)(UINT)(id), 0L)
  514. /* void Cls_OnInitMenu(HWND hwnd, HMENU hMenu) */
  515. #define HANDLE_WM_INITMENU(hwnd, wParam, lParam, fn) \
  516. ((fn)((hwnd), (HMENU)(wParam)), 0L)
  517. #define FORWARD_WM_INITMENU(hwnd, hMenu, fn) \
  518. (void)(fn)((hwnd), WM_INITMENU, (WPARAM)(HMENU)(hMenu), 0L)
  519. /* void Cls_OnInitMenuPopup(HWND hwnd, HMENU hMenu, UINT item, BOOL fSystemMenu) */
  520. #define HANDLE_WM_INITMENUPOPUP(hwnd, wParam, lParam, fn) \
  521. ((fn)((hwnd), (HMENU)(wParam), (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam)), 0L)
  522. #define FORWARD_WM_INITMENUPOPUP(hwnd, hMenu, item, fSystemMenu, fn) \
  523. (void)(fn)((hwnd), WM_INITMENUPOPUP, (WPARAM)(HMENU)(hMenu), MAKELPARAM((item),(fSystemMenu)))
  524. /* void Cls_OnMenuSelect(HWND hwnd, HMENU hmenu, int item, HMENU hmenuPopup, UINT flags) */
  525. #define HANDLE_WM_MENUSELECT(hwnd, wParam, lParam, fn) \
  526. ((fn)((hwnd), (HMENU)(lParam), \
  527. (HIWORD(wParam) & MF_POPUP) ? 0L : (int)(LOWORD(wParam)), \
  528. (HIWORD(wParam) & MF_POPUP) ? GetSubMenu((HMENU)lParam, LOWORD(wParam)) : 0L, \
  529. (UINT)(((short)HIWORD(wParam) == -1) ? 0xFFFFFFFF : HIWORD(wParam))), 0L)
  530. #define FORWARD_WM_MENUSELECT(hwnd, hmenu, item, hmenuPopup, flags, fn) \
  531. (void)(fn)((hwnd), WM_MENUSELECT, MAKEWPARAM((item), (flags)), (LPARAM)(HMENU)((hmenu) ? (hmenu) : (hmenuPopup)))
  532. /* DWORD Cls_OnMenuChar(HWND hwnd, UINT ch, UINT flags, HMENU hmenu) */
  533. #define HANDLE_WM_MENUCHAR(hwnd, wParam, lParam, fn) \
  534. (LRESULT)(DWORD)(fn)((hwnd), (UINT)(LOWORD(wParam)), (UINT)HIWORD(wParam), (HMENU)(lParam))
  535. #define FORWARD_WM_MENUCHAR(hwnd, ch, flags, hmenu, fn) \
  536. (DWORD)(fn)((hwnd), WM_MENUCHAR, MAKEWPARAM(flags, (WORD)(ch)), (LPARAM)(HMENU)(hmenu))
  537. /* void Cls_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) */
  538. #define HANDLE_WM_COMMAND(hwnd, wParam, lParam, fn) \
  539. ((fn)((hwnd), (int)(LOWORD(wParam)), (HWND)(lParam), (UINT)HIWORD(wParam)), 0L)
  540. #define FORWARD_WM_COMMAND(hwnd, id, hwndCtl, codeNotify, fn) \
  541. (void)(fn)((hwnd), WM_COMMAND, MAKEWPARAM((UINT)(id),(UINT)(codeNotify)), (LPARAM)(HWND)(hwndCtl))
  542. /* void Cls_OnHScroll(HWND hwnd, HWND hwndCtl, UINT code, int pos) */
  543. #define HANDLE_WM_HSCROLL(hwnd, wParam, lParam, fn) \
  544. ((fn)((hwnd), (HWND)(lParam), (UINT)(LOWORD(wParam)), (int)(short)HIWORD(wParam)), 0L)
  545. #define FORWARD_WM_HSCROLL(hwnd, hwndCtl, code, pos, fn) \
  546. (void)(fn)((hwnd), WM_HSCROLL, MAKEWPARAM((UINT)(int)(code),(UINT)(int)(pos)), (LPARAM)(HWND)(hwndCtl))
  547. /* void Cls_OnVScroll(HWND hwnd, HWND hwndCtl, UINT code, int pos) */
  548. #define HANDLE_WM_VSCROLL(hwnd, wParam, lParam, fn) \
  549. ((fn)((hwnd), (HWND)(lParam), (UINT)(LOWORD(wParam)), (int)(short)HIWORD(wParam)), 0L)
  550. #define FORWARD_WM_VSCROLL(hwnd, hwndCtl, code, pos, fn) \
  551. (void)(fn)((hwnd), WM_VSCROLL, MAKEWPARAM((UINT)(int)(code), (UINT)(int)(pos)), (LPARAM)(HWND)(hwndCtl))
  552. /* void Cls_OnCut(HWND hwnd) */
  553. #define HANDLE_WM_CUT(hwnd, wParam, lParam, fn) \
  554. ((fn)(hwnd), 0L)
  555. #define FORWARD_WM_CUT(hwnd, fn) \
  556. (void)(fn)((hwnd), WM_CUT, 0L, 0L)
  557. /* void Cls_OnCopy(HWND hwnd) */
  558. #define HANDLE_WM_COPY(hwnd, wParam, lParam, fn) \
  559. ((fn)(hwnd), 0L)
  560. #define FORWARD_WM_COPY(hwnd, fn) \
  561. (void)(fn)((hwnd), WM_COPY, 0L, 0L)
  562. /* void Cls_OnPaste(HWND hwnd) */
  563. #define HANDLE_WM_PASTE(hwnd, wParam, lParam, fn) \
  564. ((fn)(hwnd), 0L)
  565. #define FORWARD_WM_PASTE(hwnd, fn) \
  566. (void)(fn)((hwnd), WM_PASTE, 0L, 0L)
  567. /* void Cls_OnClear(HWND hwnd) */
  568. #define HANDLE_WM_CLEAR(hwnd, wParam, lParam, fn) \
  569. ((fn)(hwnd), 0L)
  570. #define FORWARD_WM_CLEAR(hwnd, fn) \
  571. (void)(fn)((hwnd), WM_CLEAR, 0L, 0L)
  572. /* void Cls_OnUndo(HWND hwnd) */
  573. #define HANDLE_WM_UNDO(hwnd, wParam, lParam, fn) \
  574. ((fn)(hwnd), 0L)
  575. #define FORWARD_WM_UNDO(hwnd, fn) \
  576. (void)(fn)((hwnd), WM_UNDO, 0L, 0L)
  577. /* HANDLE Cls_OnRenderFormat(HWND hwnd, UINT fmt) */
  578. #define HANDLE_WM_RENDERFORMAT(hwnd, wParam, lParam, fn) \
  579. (LRESULT)(UINT_PTR)(HANDLE)(fn)((hwnd), (UINT)(wParam))
  580. #define FORWARD_WM_RENDERFORMAT(hwnd, fmt, fn) \
  581. (HANDLE)(UINT_PTR)(fn)((hwnd), WM_RENDERFORMAT, (WPARAM)(UINT)(fmt), 0L)
  582. /* void Cls_OnRenderAllFormats(HWND hwnd) */
  583. #define HANDLE_WM_RENDERALLFORMATS(hwnd, wParam, lParam, fn) \
  584. ((fn)(hwnd), 0L)
  585. #define FORWARD_WM_RENDERALLFORMATS(hwnd, fn) \
  586. (void)(fn)((hwnd), WM_RENDERALLFORMATS, 0L, 0L)
  587. /* void Cls_OnDestroyClipboard(HWND hwnd) */
  588. #define HANDLE_WM_DESTROYCLIPBOARD(hwnd, wParam, lParam, fn) \
  589. ((fn)(hwnd), 0L)
  590. #define FORWARD_WM_DESTROYCLIPBOARD(hwnd, fn) \
  591. (void)(fn)((hwnd), WM_DESTROYCLIPBOARD, 0L, 0L)
  592. /* void Cls_OnDrawClipboard(HWND hwnd) */
  593. #define HANDLE_WM_DRAWCLIPBOARD(hwnd, wParam, lParam, fn) \
  594. ((fn)(hwnd), 0L)
  595. #define FORWARD_WM_DRAWCLIPBOARD(hwnd, fn) \
  596. (void)(fn)((hwnd), WM_DRAWCLIPBOARD, 0L, 0L)
  597. /* void Cls_OnPaintClipboard(HWND hwnd, HWND hwndCBViewer, const LPPAINTSTRUCT lpPaintStruct) */
  598. #define HANDLE_WM_PAINTCLIPBOARD(hwnd, wParam, lParam, fn) \
  599. ((fn)((hwnd), (HWND)(wParam), (const LPPAINTSTRUCT)GlobalLock((HGLOBAL)(lParam))), GlobalUnlock((HGLOBAL)(lParam)), 0L)
  600. #define FORWARD_WM_PAINTCLIPBOARD(hwnd, hwndCBViewer, lpPaintStruct, fn) \
  601. (void)(fn)((hwnd), WM_PAINTCLIPBOARD, (WPARAM)(HWND)(hwndCBViewer), (LPARAM)(LPPAINTSTRUCT)(lpPaintStruct))
  602. /* void Cls_OnSizeClipboard(HWND hwnd, HWND hwndCBViewer, const LPRECT lprc) */
  603. #define HANDLE_WM_SIZECLIPBOARD(hwnd, wParam, lParam, fn) \
  604. ((fn)((hwnd), (HWND)(wParam), (const LPRECT)GlobalLock((HGLOBAL)(lParam))), GlobalUnlock((HGLOBAL)(lParam)), 0L)
  605. #define FORWARD_WM_SIZECLIPBOARD(hwnd, hwndCBViewer, lprc, fn) \
  606. (void)(fn)((hwnd), WM_SIZECLIPBOARD, (WPARAM)(HWND)(hwndCBViewer), (LPARAM)(LPRECT)(lprc))
  607. /* void Cls_OnVScrollClipboard(HWND hwnd, HWND hwndCBViewer, UINT code, int pos) */
  608. #define HANDLE_WM_VSCROLLCLIPBOARD(hwnd, wParam, lParam, fn) \
  609. ((fn)((hwnd), (HWND)(wParam), (UINT)LOWORD(lParam), (int)(short)HIWORD(lParam)), 0L)
  610. #define FORWARD_WM_VSCROLLCLIPBOARD(hwnd, hwndCBViewer, code, pos, fn) \
  611. (void)(fn)((hwnd), WM_VSCROLLCLIPBOARD, (WPARAM)(HWND)(hwndCBViewer), MAKELPARAM((code), (pos)))
  612. /* void Cls_OnHScrollClipboard(HWND hwnd, HWND hwndCBViewer, UINT code, int pos) */
  613. #define HANDLE_WM_HSCROLLCLIPBOARD(hwnd, wParam, lParam, fn) \
  614. ((fn)((hwnd), (HWND)(wParam), (UINT)LOWORD(lParam), (int)(short)HIWORD(lParam)), 0L)
  615. #define FORWARD_WM_HSCROLLCLIPBOARD(hwnd, hwndCBViewer, code, pos, fn) \
  616. (void)(fn)((hwnd), WM_HSCROLLCLIPBOARD, (WPARAM)(HWND)(hwndCBViewer), MAKELPARAM((code), (pos)))
  617. /* void Cls_OnAskCBFormatName(HWND hwnd, int cchMax, LPTSTR rgchName) */
  618. #define HANDLE_WM_ASKCBFORMATNAME(hwnd, wParam, lParam, fn) \
  619. ((fn)((hwnd), (int)(wParam), (LPTSTR)(lParam)), 0L)
  620. #define FORWARD_WM_ASKCBFORMATNAME(hwnd, cchMax, rgchName, fn) \
  621. (void)(fn)((hwnd), WM_ASKCBFORMATNAME, (WPARAM)(int)(cchMax), (LPARAM)(rgchName))
  622. /* void Cls_OnChangeCBChain(HWND hwnd, HWND hwndRemove, HWND hwndNext) */
  623. #define HANDLE_WM_CHANGECBCHAIN(hwnd, wParam, lParam, fn) \
  624. ((fn)((hwnd), (HWND)(wParam), (HWND)(lParam)), 0L)
  625. #define FORWARD_WM_CHANGECBCHAIN(hwnd, hwndRemove, hwndNext, fn) \
  626. (void)(fn)((hwnd), WM_CHANGECBCHAIN, (WPARAM)(HWND)(hwndRemove), (LPARAM)(HWND)(hwndNext))
  627. /* BOOL Cls_OnSetCursor(HWND hwnd, HWND hwndCursor, UINT codeHitTest, UINT msg) */
  628. #define HANDLE_WM_SETCURSOR(hwnd, wParam, lParam, fn) \
  629. (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (HWND)(wParam), (UINT)LOWORD(lParam), (UINT)HIWORD(lParam))
  630. #define FORWARD_WM_SETCURSOR(hwnd, hwndCursor, codeHitTest, msg, fn) \
  631. (BOOL)(DWORD)(fn)((hwnd), WM_SETCURSOR, (WPARAM)(HWND)(hwndCursor), MAKELPARAM((codeHitTest), (msg)))
  632. /* void Cls_OnSysCommand(HWND hwnd, UINT cmd, int x, int y) */
  633. #define HANDLE_WM_SYSCOMMAND(hwnd, wParam, lParam, fn) \
  634. ((fn)((hwnd), (UINT)(wParam), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)), 0L)
  635. #define FORWARD_WM_SYSCOMMAND(hwnd, cmd, x, y, fn) \
  636. (void)(fn)((hwnd), WM_SYSCOMMAND, (WPARAM)(UINT)(cmd), MAKELPARAM((x), (y)))
  637. /* HWND Cls_MDICreate(HWND hwnd, const LPMDICREATESTRUCT lpmcs) */
  638. #define HANDLE_WM_MDICREATE(hwnd, wParam, lParam, fn) \
  639. (LRESULT)(DWORD)(UINT)(fn)((hwnd), (LPMDICREATESTRUCT)(lParam))
  640. #define FORWARD_WM_MDICREATE(hwnd, lpmcs, fn) \
  641. (HWND)(UINT)(DWORD)(fn)((hwnd), WM_MDICREATE, 0L, (LPARAM)(LPMDICREATESTRUCT)(lpmcs))
  642. /* void Cls_MDIDestroy(HWND hwnd, HWND hwndDestroy) */
  643. #define HANDLE_WM_MDIDESTROY(hwnd, wParam, lParam, fn) \
  644. ((fn)((hwnd), (HWND)(wParam)), 0L)
  645. #define FORWARD_WM_MDIDESTROY(hwnd, hwndDestroy, fn) \
  646. (void)(fn)((hwnd), WM_MDIDESTROY, (WPARAM)(hwndDestroy), 0L)
  647. /* NOTE: Usable only by MDI client windows */
  648. /* void Cls_MDIActivate(HWND hwnd, BOOL fActive, HWND hwndActivate, HWND hwndDeactivate) */
  649. #define HANDLE_WM_MDIACTIVATE(hwnd, wParam, lParam, fn) \
  650. ((fn)((hwnd), (BOOL)(lParam == (LPARAM)hwnd), (HWND)(lParam), (HWND)(wParam)), 0L)
  651. #define FORWARD_WM_MDIACTIVATE(hwnd, fActive, hwndActivate, hwndDeactivate, fn) \
  652. (void)(fn)(hwnd, WM_MDIACTIVATE, (WPARAM)(hwndDeactivate), (LPARAM)(hwndActivate))
  653. /* void Cls_MDIRestore(HWND hwnd, HWND hwndRestore) */
  654. #define HANDLE_WM_MDIRESTORE(hwnd, wParam, lParam, fn) \
  655. ((fn)((hwnd), (HWND)(wParam)), 0L)
  656. #define FORWARD_WM_MDIRESTORE(hwnd, hwndRestore, fn) \
  657. (void)(fn)((hwnd), WM_MDIRESTORE, (WPARAM)(hwndRestore), 0L)
  658. /* HWND Cls_MDINext(HWND hwnd, HWND hwndCur, BOOL fPrev) */
  659. #define HANDLE_WM_MDINEXT(hwnd, wParam, lParam, fn) \
  660. (LRESULT)(HWND)(fn)((hwnd), (HWND)(wParam), (BOOL)lParam)
  661. #define FORWARD_WM_MDINEXT(hwnd, hwndCur, fPrev, fn) \
  662. (HWND)(UINT_PTR)(fn)((hwnd), WM_MDINEXT, (WPARAM)(hwndCur), (LPARAM)(fPrev))
  663. /* void Cls_MDIMaximize(HWND hwnd, HWND hwndMaximize) */
  664. #define HANDLE_WM_MDIMAXIMIZE(hwnd, wParam, lParam, fn) \
  665. ((fn)((hwnd), (HWND)(wParam)), 0L)
  666. #define FORWARD_WM_MDIMAXIMIZE(hwnd, hwndMaximize, fn) \
  667. (void)(fn)((hwnd), WM_MDIMAXIMIZE, (WPARAM)(hwndMaximize), 0L)
  668. /* BOOL Cls_MDITile(HWND hwnd, UINT cmd) */
  669. #define HANDLE_WM_MDITILE(hwnd, wParam, lParam, fn) \
  670. (LRESULT)(DWORD)(fn)((hwnd), (UINT)(wParam))
  671. #define FORWARD_WM_MDITILE(hwnd, cmd, fn) \
  672. (BOOL)(DWORD)(fn)((hwnd), WM_MDITILE, (WPARAM)(cmd), 0L)
  673. /* BOOL Cls_MDICascade(HWND hwnd, UINT cmd) */
  674. #define HANDLE_WM_MDICASCADE(hwnd, wParam, lParam, fn) \
  675. (LRESULT)(DWORD)(fn)((hwnd), (UINT)(wParam))
  676. #define FORWARD_WM_MDICASCADE(hwnd, cmd, fn) \
  677. (BOOL)(DWORD)(fn)((hwnd), WM_MDICASCADE, (WPARAM)(cmd), 0L)
  678. /* void Cls_MDIIconArrange(HWND hwnd) */
  679. #define HANDLE_WM_MDIICONARRANGE(hwnd, wParam, lParam, fn) \
  680. ((fn)(hwnd), 0L)
  681. #define FORWARD_WM_MDIICONARRANGE(hwnd, fn) \
  682. (void)(fn)((hwnd), WM_MDIICONARRANGE, 0L, 0L)
  683. /* HWND Cls_MDIGetActive(HWND hwnd) */
  684. #define HANDLE_WM_MDIGETACTIVE(hwnd, wParam, lParam, fn) \
  685. (LRESULT)(UINT_PTR)(fn)(hwnd)
  686. #define FORWARD_WM_MDIGETACTIVE(hwnd, fn) \
  687. (HWND)(UINT_PTR)(fn)((hwnd), WM_MDIGETACTIVE, 0L, 0L)
  688. /* HMENU Cls_MDISetMenu(HWND hwnd, BOOL fRefresh, HMENU hmenuFrame, HMENU hmenuWindow) */
  689. #define HANDLE_WM_MDISETMENU(hwnd, wParam, lParam, fn) \
  690. (LRESULT)(UINT_PTR)(fn)((hwnd), (BOOL)(wParam), (HMENU)(wParam), (HMENU)(lParam))
  691. #define FORWARD_WM_MDISETMENU(hwnd, fRefresh, hmenuFrame, hmenuWindow, fn) \
  692. (HMENU)(UINT_PTR)(fn)((hwnd), WM_MDISETMENU, (WPARAM)((fRefresh) ? (hmenuFrame) : 0), (LPARAM)(hmenuWindow))
  693. /* void Cls_OnChildActivate(HWND hwnd) */
  694. #define HANDLE_WM_CHILDACTIVATE(hwnd, wParam, lParam, fn) \
  695. ((fn)(hwnd), 0L)
  696. #define FORWARD_WM_CHILDACTIVATE(hwnd, fn) \
  697. (void)(fn)((hwnd), WM_CHILDACTIVATE, 0L, 0L)
  698. /* BOOL Cls_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) */
  699. #define HANDLE_WM_INITDIALOG(hwnd, wParam, lParam, fn) \
  700. (LRESULT)(DWORD)(UINT)(BOOL)(fn)((hwnd), (HWND)(wParam), lParam)
  701. #define FORWARD_WM_INITDIALOG(hwnd, hwndFocus, lParam, fn) \
  702. (BOOL)(DWORD)(fn)((hwnd), WM_INITDIALOG, (WPARAM)(HWND)(hwndFocus), (lParam))
  703. /* HWND Cls_OnNextDlgCtl(HWND hwnd, HWND hwndSetFocus, BOOL fNext) */
  704. #define HANDLE_WM_NEXTDLGCTL(hwnd, wParam, lParam, fn) \
  705. (LRESULT)(UINT_PTR)(HWND)(fn)((hwnd), (HWND)(wParam), (BOOL)(lParam))
  706. #define FORWARD_WM_NEXTDLGCTL(hwnd, hwndSetFocus, fNext, fn) \
  707. (HWND)(UINT_PTR)(fn)((hwnd), WM_NEXTDLGCTL, (WPARAM)(HWND)(hwndSetFocus), (LPARAM)(fNext))
  708. /* void Cls_OnParentNotify(HWND hwnd, UINT msg, HWND hwndChild, int idChild) */
  709. #define HANDLE_WM_PARENTNOTIFY(hwnd, wParam, lParam, fn) \
  710. ((fn)((hwnd), (UINT)LOWORD(wParam), (HWND)(lParam), (UINT)HIWORD(wParam)), 0L)
  711. #define FORWARD_WM_PARENTNOTIFY(hwnd, msg, hwndChild, idChild, fn) \
  712. (void)(fn)((hwnd), WM_PARENTNOTIFY, MAKEWPARAM(msg, idChild), (LPARAM)(hwndChild))
  713. /* void Cls_OnEnterIdle(HWND hwnd, UINT source, HWND hwndSource) */
  714. #define HANDLE_WM_ENTERIDLE(hwnd, wParam, lParam, fn) \
  715. ((fn)((hwnd), (UINT)(wParam), (HWND)(lParam)), 0L)
  716. #define FORWARD_WM_ENTERIDLE(hwnd, source, hwndSource, fn) \
  717. (void)(fn)((hwnd), WM_ENTERIDLE, (WPARAM)(UINT)(source), (LPARAM)(HWND)(hwndSource))
  718. /* UINT Cls_OnGetDlgCode(HWND hwnd, LPMSG lpmsg) */
  719. #define HANDLE_WM_GETDLGCODE(hwnd, wParam, lParam, fn) \
  720. (LRESULT)(DWORD)(UINT)(fn)(hwnd, (LPMSG)(lParam))
  721. #define FORWARD_WM_GETDLGCODE(hwnd, lpmsg, fn) \
  722. (UINT)(DWORD)(fn)((hwnd), WM_GETDLGCODE, (lpmsg ? lpmsg->wParam : 0), (LPARAM)(LPMSG)(lpmsg))
  723. /* HBRUSH Cls_OnCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type) */
  724. #define HANDLE_WM_CTLCOLORMSGBOX(hwnd, wParam, lParam, fn) \
  725. (LRESULT)(UINT_PTR)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_MSGBOX)
  726. #define FORWARD_WM_CTLCOLORMSGBOX(hwnd, hdc, hwndChild, fn) \
  727. (HBRUSH)(UINT_PTR)(fn)((hwnd), WM_CTLCOLORMSGBOX, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
  728. #define HANDLE_WM_CTLCOLOREDIT(hwnd, wParam, lParam, fn) \
  729. (LRESULT)(UINT_PTR)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_EDIT)
  730. #define FORWARD_WM_CTLCOLOREDIT(hwnd, hdc, hwndChild, fn) \
  731. (HBRUSH)(UINT_PTR)(fn)((hwnd), WM_CTLCOLOREDIT, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
  732. #define HANDLE_WM_CTLCOLORLISTBOX(hwnd, wParam, lParam, fn) \
  733. (LRESULT)(UINT_PTR)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_LISTBOX)
  734. #define FORWARD_WM_CTLCOLORLISTBOX(hwnd, hdc, hwndChild, fn) \
  735. (HBRUSH)(UINT_PTR)(fn)((hwnd), WM_CTLCOLORLISTBOX, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
  736. #define HANDLE_WM_CTLCOLORBTN(hwnd, wParam, lParam, fn) \
  737. (LRESULT)(UINT_PTR)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_BTN)
  738. #define FORWARD_WM_CTLCOLORBTN(hwnd, hdc, hwndChild, fn) \
  739. (HBRUSH)(UINT_PTR)(fn)((hwnd), WM_CTLCOLORBTN, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
  740. #define HANDLE_WM_CTLCOLORDLG(hwnd, wParam, lParam, fn) \
  741. (LRESULT)(UINT_PTR)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_DLG)
  742. #define FORWARD_WM_CTLCOLORDLG(hwnd, hdc, hwndChild, fn) \
  743. (HBRUSH)(UINT_PTR)(fn)((hwnd), WM_CTLCOLORDLG, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
  744. #define HANDLE_WM_CTLCOLORSCROLLBAR(hwnd, wParam, lParam, fn) \
  745. (LRESULT)(UINT_PTR)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_SCROLLBAR)
  746. #define FORWARD_WM_CTLCOLORSCROLLBAR(hwnd, hdc, hwndChild, fn) \
  747. (HBRUSH)(UINT_PTR)(fn)((hwnd), WM_CTLCOLORSCROLLBAR, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
  748. #define HANDLE_WM_CTLCOLORSTATIC(hwnd, wParam, lParam, fn) \
  749. (LRESULT)(UINT_PTR)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_STATIC)
  750. #define FORWARD_WM_CTLCOLORSTATIC(hwnd, hdc, hwndChild, fn) \
  751. (HBRUSH)(UINT_PTR)(fn)((hwnd), WM_CTLCOLORSTATIC, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
  752. /* void Cls_OnSetFont(HWND hwndCtl, HFONT hfont, BOOL fRedraw) */
  753. #define HANDLE_WM_SETFONT(hwnd, wParam, lParam, fn) \
  754. ((fn)((hwnd), (HFONT)(wParam), (BOOL)(lParam)), 0L)
  755. #define FORWARD_WM_SETFONT(hwnd, hfont, fRedraw, fn) \
  756. (void)(fn)((hwnd), WM_SETFONT, (WPARAM)(HFONT)(hfont), (LPARAM)(BOOL)(fRedraw))
  757. /* HFONT Cls_OnGetFont(HWND hwnd) */
  758. #define HANDLE_WM_GETFONT(hwnd, wParam, lParam, fn) \
  759. (LRESULT)(UINT_PTR)(HFONT)(fn)(hwnd)
  760. #define FORWARD_WM_GETFONT(hwnd, fn) \
  761. (HFONT)(UINT_PTR)(fn)((hwnd), WM_GETFONT, 0L, 0L)
  762. /* void Cls_OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT * lpDrawItem) */
  763. #define HANDLE_WM_DRAWITEM(hwnd, wParam, lParam, fn) \
  764. ((fn)((hwnd), (const DRAWITEMSTRUCT *)(lParam)), 0L)
  765. #define FORWARD_WM_DRAWITEM(hwnd, lpDrawItem, fn) \
  766. (void)(fn)((hwnd), WM_DRAWITEM, (WPARAM)(((const DRAWITEMSTRUCT *)lpDrawItem)->CtlID), (LPARAM)(const DRAWITEMSTRUCT *)(lpDrawItem))
  767. /* void Cls_OnMeasureItem(HWND hwnd, MEASUREITEMSTRUCT * lpMeasureItem) */
  768. #define HANDLE_WM_MEASUREITEM(hwnd, wParam, lParam, fn) \
  769. ((fn)((hwnd), (MEASUREITEMSTRUCT *)(lParam)), 0L)
  770. #define FORWARD_WM_MEASUREITEM(hwnd, lpMeasureItem, fn) \
  771. (void)(fn)((hwnd), WM_MEASUREITEM, (WPARAM)(((MEASUREITEMSTRUCT *)lpMeasureItem)->CtlID), (LPARAM)(MEASUREITEMSTRUCT *)(lpMeasureItem))
  772. /* void Cls_OnDeleteItem(HWND hwnd, const DELETEITEMSTRUCT * lpDeleteItem) */
  773. #define HANDLE_WM_DELETEITEM(hwnd, wParam, lParam, fn) \
  774. ((fn)((hwnd), (const DELETEITEMSTRUCT *)(lParam)), 0L)
  775. #define FORWARD_WM_DELETEITEM(hwnd, lpDeleteItem, fn) \
  776. (void)(fn)((hwnd), WM_DELETEITEM, (WPARAM)(((const DELETEITEMSTRUCT *)(lpDeleteItem))->CtlID), (LPARAM)(const DELETEITEMSTRUCT *)(lpDeleteItem))
  777. /* int Cls_OnCompareItem(HWND hwnd, const COMPAREITEMSTRUCT * lpCompareItem) */
  778. #define HANDLE_WM_COMPAREITEM(hwnd, wParam, lParam, fn) \
  779. (LRESULT)(DWORD)(int)(fn)((hwnd), (const COMPAREITEMSTRUCT *)(lParam))
  780. #define FORWARD_WM_COMPAREITEM(hwnd, lpCompareItem, fn) \
  781. (int)(DWORD)(fn)((hwnd), WM_COMPAREITEM, (WPARAM)(((const COMPAREITEMSTRUCT *)(lpCompareItem))->CtlID), (LPARAM)(const COMPAREITEMSTRUCT *)(lpCompareItem))
  782. /* int Cls_OnVkeyToItem(HWND hwnd, UINT vk, HWND hwndListbox, int iCaret) */
  783. #define HANDLE_WM_VKEYTOITEM(hwnd, wParam, lParam, fn) \
  784. (LRESULT)(DWORD)(int)(fn)((hwnd), (UINT)LOWORD(wParam), (HWND)(lParam), (int)(short)HIWORD(wParam))
  785. #define FORWARD_WM_VKEYTOITEM(hwnd, vk, hwndListBox, iCaret, fn) \
  786. (int)(DWORD)(fn)((hwnd), WM_VKEYTOITEM, MAKEWPARAM((vk), (iCaret)), (LPARAM)(hwndListBox))
  787. /* int Cls_OnCharToItem(HWND hwnd, UINT ch, HWND hwndListbox, int iCaret) */
  788. #define HANDLE_WM_CHARTOITEM(hwnd, wParam, lParam, fn) \
  789. (LRESULT)(DWORD)(int)(fn)((hwnd), (UINT)LOWORD(wParam), (HWND)(lParam), (int)(short)HIWORD(wParam))
  790. #define FORWARD_WM_CHARTOITEM(hwnd, ch, hwndListBox, iCaret, fn) \
  791. (int)(DWORD)(fn)((hwnd), WM_CHARTOITEM, MAKEWPARAM((UINT)(ch), (UINT)(iCaret)), (LPARAM)(hwndListBox))
  792. /* void Cls_OnQueueSync(HWND hwnd) */
  793. #define HANDLE_WM_QUEUESYNC(hwnd, wParam, lParam, fn) \
  794. ((fn)(hwnd), 0L)
  795. #define FORWARD_WM_QUEUESYNC(hwnd, fn) \
  796. (void)(fn)((hwnd), WM_QUEUESYNC, 0L, 0L)
  797. #if (WINVER >= 0x030a)
  798. /* void Cls_OnCommNotify(HWND hwnd, int cid, UINT flags) */
  799. #define HANDLE_WM_COMMNOTIFY(hwnd, wParam, lParam, fn) \
  800. ((fn)((hwnd), (int)(wParam), (UINT)LOWORD(lParam)), 0L)
  801. #define FORWARD_WM_COMMNOTIFY(hwnd, cid, flags, fn) \
  802. (void)(fn)((hwnd), WM_COMMNOTIFY, (WPARAM)(cid), MAKELPARAM((flags), 0))
  803. #endif
  804. /* void Cls_OnDisplayChange(HWND hwnd, UINT bitsPerPixel, UINT cxScreen, UINT cyScreen) */
  805. #define HANDLE_WM_DISPLAYCHANGE(hwnd, wParam, lParam, fn) \
  806. ((fn)((hwnd), (UINT)(wParam), (UINT)LOWORD(lParam), (UINT)HIWORD(wParam)), 0L)
  807. #define FORWARD_WM_DISPLAYCHANGE(hwnd, bitsPerPixel, cxScreen, cyScreen, fn) \
  808. (void)(fn)((hwnd), WM_DISPLAYCHANGE, (WPARAM)(UINT)(bitsPerPixel), (LPARAM)MAKELPARAM((UINT)(cxScreen), (UINT)(cyScreen)))
  809. /* BOOL Cls_OnDeviceChange(HWND hwnd, UINT uEvent, DWORD dwEventData) */
  810. #define HANDLE_WM_DEVICECHANGE(hwnd, wParam, lParam, fn) \
  811. (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (UINT)(wParam), (DWORD)(wParam))
  812. #define FORWARD_WM_DEVICECHANGE(hwnd, uEvent, dwEventData, fn) \
  813. (BOOL)(DWORD)(fn)((hwnd), WM_DEVICECHANGE, (WPARAM)(UINT)(uEvent), (LPARAM)(DWORD)(dwEventData))
  814. /* void Cls_OnContextMenu(HWND hwnd, HWND hwndContext, UINT xPos, UINT yPos) */
  815. #define HANDLE_WM_CONTEXTMENU(hwnd, wParam, lParam, fn) \
  816. ((fn)((hwnd), (HWND)(wParam), (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)), 0L)
  817. #define FORWARD_WM_CONTEXTMENU(hwnd, hwndContext, xPos, yPos, fn) \
  818. (void)(fn)((hwnd), WM_CONTEXTMENU, (WPARAM)(HWND)(hwndContext), MAKELPARAM((UINT)(xPos), (UINT)(yPos)))
  819. #define HANDLE_WM_COPYDATA(hwnd, wParam, lParam, fn) \
  820. ((fn)((hwnd), (HWND)(wParam), (PCOPYDATASTRUCT)lParam), 0L)
  821. #define FORWARD_WM_COPYDATA(hwnd, hwndFrom, pcds, fn) \
  822. (BOOL)(UINT)(DWORD)(fn)((hwnd), WM_COPYDATA, (WPARAM)(hwndFrom), (LPARAM)(pcds))
  823. /* void Cls_OnHotKey(HWND hwnd, int idHotKey, UINT fuModifiers, UINT vk) */
  824. #define HANDLE_WM_HOTKEY(hwnd, wParam, lParam, fn) \
  825. ((fn)((hwnd), (int)(wParam), (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)), 0L)
  826. #define FORWARD_WM_HOTKEY(hwnd, idHotKey, fuModifiers, vk, fn) \
  827. (void)(fn)((hwnd), WM_HOTKEY, (WPARAM)(idHotKey), MAKELPARAM((fuModifiers), (vk)))
  828. /****** Static control message APIs ******************************************/
  829. #define Static_Enable(hwndCtl, fEnable) EnableWindow((hwndCtl), (fEnable))
  830. #define Static_GetText(hwndCtl, lpch, cchMax) GetWindowText((hwndCtl), (lpch), (cchMax))
  831. #define Static_GetTextLength(hwndCtl) GetWindowTextLength(hwndCtl)
  832. #define Static_SetText(hwndCtl, lpsz) SetWindowText((hwndCtl), (lpsz))
  833. #define Static_SetIcon(hwndCtl, hIcon) ((HICON)(UINT_PTR)SNDMSG((hwndCtl), STM_SETICON, (WPARAM)(HICON)(hIcon), 0L))
  834. #define Static_GetIcon(hwndCtl, hIcon) ((HICON)(UINT_PTR)SNDMSG((hwndCtl), STM_GETICON, 0L, 0L))
  835. /****** Button control message APIs ******************************************/
  836. #define Button_Enable(hwndCtl, fEnable) EnableWindow((hwndCtl), (fEnable))
  837. #define Button_GetText(hwndCtl, lpch, cchMax) GetWindowText((hwndCtl), (lpch), (cchMax))
  838. #define Button_GetTextLength(hwndCtl) GetWindowTextLength(hwndCtl)
  839. #define Button_SetText(hwndCtl, lpsz) SetWindowText((hwndCtl), (lpsz))
  840. #define Button_GetCheck(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), BM_GETCHECK, 0L, 0L))
  841. #define Button_SetCheck(hwndCtl, check) ((void)SNDMSG((hwndCtl), BM_SETCHECK, (WPARAM)(int)(check), 0L))
  842. #define Button_GetState(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), BM_GETSTATE, 0L, 0L))
  843. #define Button_SetState(hwndCtl, state) ((UINT)(DWORD)SNDMSG((hwndCtl), BM_SETSTATE, (WPARAM)(int)(state), 0L))
  844. #define Button_SetStyle(hwndCtl, style, fRedraw) ((void)SNDMSG((hwndCtl), BM_SETSTYLE, (WPARAM)LOWORD(style), MAKELPARAM(((fRedraw) ? TRUE : FALSE), 0)))
  845. /****** Edit control message APIs ********************************************/
  846. #define Edit_Enable(hwndCtl, fEnable) EnableWindow((hwndCtl), (fEnable))
  847. #define Edit_GetText(hwndCtl, lpch, cchMax) GetWindowText((hwndCtl), (lpch), (cchMax))
  848. #define Edit_GetTextLength(hwndCtl) GetWindowTextLength(hwndCtl)
  849. #define Edit_SetText(hwndCtl, lpsz) SetWindowText((hwndCtl), (lpsz))
  850. #define Edit_LimitText(hwndCtl, cchMax) ((void)SNDMSG((hwndCtl), EM_LIMITTEXT, (WPARAM)(cchMax), 0L))
  851. #define Edit_GetLineCount(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), EM_GETLINECOUNT, 0L, 0L))
  852. #ifndef _MAC
  853. #define Edit_GetLine(hwndCtl, line, lpch, cchMax) ((*((int *)(lpch)) = (cchMax)), ((int)(DWORD)SNDMSG((hwndCtl), EM_GETLINE, (WPARAM)(int)(line), (LPARAM)(LPTSTR)(lpch))))
  854. #else
  855. #define Edit_GetLine(hwndCtl, line, lpch, cchMax) ((*((WORD *)(lpch)) = (cchMax)), ((int)(DWORD)SNDMSG((hwndCtl), EM_GETLINE, (WPARAM)(int)(line), (LPARAM)(LPTSTR)(lpch))))
  856. #endif
  857. #define Edit_GetRect(hwndCtl, lprc) ((void)SNDMSG((hwndCtl), EM_GETRECT, 0L, (LPARAM)(RECT *)(lprc)))
  858. #define Edit_SetRect(hwndCtl, lprc) ((void)SNDMSG((hwndCtl), EM_SETRECT, 0L, (LPARAM)(const RECT *)(lprc)))
  859. #define Edit_SetRectNoPaint(hwndCtl, lprc) ((void)SNDMSG((hwndCtl), EM_SETRECTNP, 0L, (LPARAM)(const RECT *)(lprc)))
  860. #define Edit_GetSel(hwndCtl) ((DWORD)SNDMSG((hwndCtl), EM_GETSEL, 0L, 0L))
  861. #define Edit_SetSel(hwndCtl, ichStart, ichEnd) ((void)SNDMSG((hwndCtl), EM_SETSEL, (ichStart), (ichEnd)))
  862. #define Edit_ReplaceSel(hwndCtl, lpszReplace) ((void)SNDMSG((hwndCtl), EM_REPLACESEL, 0L, (LPARAM)(LPCTSTR)(lpszReplace)))
  863. #define Edit_GetModify(hwndCtl) ((BOOL)(DWORD)SNDMSG((hwndCtl), EM_GETMODIFY, 0L, 0L))
  864. #define Edit_SetModify(hwndCtl, fModified) ((void)SNDMSG((hwndCtl), EM_SETMODIFY, (WPARAM)(UINT)(fModified), 0L))
  865. #define Edit_ScrollCaret(hwndCtl) ((BOOL)(DWORD)SNDMSG((hwndCtl), EM_SCROLLCARET, 0, 0L))
  866. #define Edit_LineFromChar(hwndCtl, ich) ((int)(DWORD)SNDMSG((hwndCtl), EM_LINEFROMCHAR, (WPARAM)(int)(ich), 0L))
  867. #define Edit_LineIndex(hwndCtl, line) ((int)(DWORD)SNDMSG((hwndCtl), EM_LINEINDEX, (WPARAM)(int)(line), 0L))
  868. #define Edit_LineLength(hwndCtl, line) ((int)(DWORD)SNDMSG((hwndCtl), EM_LINELENGTH, (WPARAM)(int)(line), 0L))
  869. #define Edit_Scroll(hwndCtl, dv, dh) ((void)SNDMSG((hwndCtl), EM_LINESCROLL, (WPARAM)(dh), (LPARAM)(dv)))
  870. #define Edit_CanUndo(hwndCtl) ((BOOL)(DWORD)SNDMSG((hwndCtl), EM_CANUNDO, 0L, 0L))
  871. #define Edit_Undo(hwndCtl) ((BOOL)(DWORD)SNDMSG((hwndCtl), EM_UNDO, 0L, 0L))
  872. #define Edit_EmptyUndoBuffer(hwndCtl) ((void)SNDMSG((hwndCtl), EM_EMPTYUNDOBUFFER, 0L, 0L))
  873. #define Edit_SetPasswordChar(hwndCtl, ch) ((void)SNDMSG((hwndCtl), EM_SETPASSWORDCHAR, (WPARAM)(UINT)(ch), 0L))
  874. #define Edit_SetTabStops(hwndCtl, cTabs, lpTabs) ((void)SNDMSG((hwndCtl), EM_SETTABSTOPS, (WPARAM)(int)(cTabs), (LPARAM)(const int *)(lpTabs)))
  875. #define Edit_FmtLines(hwndCtl, fAddEOL) ((BOOL)(DWORD)SNDMSG((hwndCtl), EM_FMTLINES, (WPARAM)(BOOL)(fAddEOL), 0L))
  876. #define Edit_GetHandle(hwndCtl) ((HLOCAL)(UINT_PTR)SNDMSG((hwndCtl), EM_GETHANDLE, 0L, 0L))
  877. #define Edit_SetHandle(hwndCtl, h) ((void)SNDMSG((hwndCtl), EM_SETHANDLE, (WPARAM)(UINT_PTR)(HLOCAL)(h), 0L))
  878. #if (WINVER >= 0x030a)
  879. #define Edit_GetFirstVisibleLine(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), EM_GETFIRSTVISIBLELINE, 0L, 0L))
  880. #define Edit_SetReadOnly(hwndCtl, fReadOnly) ((BOOL)(DWORD)SNDMSG((hwndCtl), EM_SETREADONLY, (WPARAM)(BOOL)(fReadOnly), 0L))
  881. #define Edit_GetPasswordChar(hwndCtl) ((TCHAR)(DWORD)SNDMSG((hwndCtl), EM_GETPASSWORDCHAR, 0L, 0L))
  882. #define Edit_SetWordBreakProc(hwndCtl, lpfnWordBreak) ((void)SNDMSG((hwndCtl), EM_SETWORDBREAKPROC, 0L, (LPARAM)(EDITWORDBREAKPROC)(lpfnWordBreak)))
  883. #define Edit_GetWordBreakProc(hwndCtl) ((EDITWORDBREAKPROC)SNDMSG((hwndCtl), EM_GETWORDBREAKPROC, 0L, 0L))
  884. #endif /* WINVER >= 0x030a */
  885. /****** ScrollBar control message APIs ***************************************/
  886. /* NOTE: flags parameter is a collection of ESB_* values, NOT a boolean! */
  887. #define ScrollBar_Enable(hwndCtl, flags) EnableScrollBar((hwndCtl), SB_CTL, (flags))
  888. #define ScrollBar_Show(hwndCtl, fShow) ShowWindow((hwndCtl), (fShow) ? SW_SHOWNORMAL : SW_HIDE)
  889. #define ScrollBar_SetPos(hwndCtl, pos, fRedraw) SetScrollPos((hwndCtl), SB_CTL, (pos), (fRedraw))
  890. #define ScrollBar_GetPos(hwndCtl) GetScrollPos((hwndCtl), SB_CTL)
  891. #define ScrollBar_SetRange(hwndCtl, posMin, posMax, fRedraw) SetScrollRange((hwndCtl), SB_CTL, (posMin), (posMax), (fRedraw))
  892. #define ScrollBar_GetRange(hwndCtl, lpposMin, lpposMax) GetScrollRange((hwndCtl), SB_CTL, (lpposMin), (lpposMax))
  893. /****** ListBox control message APIs *****************************************/
  894. #define ListBox_Enable(hwndCtl, fEnable) EnableWindow((hwndCtl), (fEnable))
  895. #define ListBox_GetCount(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), LB_GETCOUNT, 0L, 0L))
  896. #define ListBox_ResetContent(hwndCtl) ((BOOL)(DWORD)SNDMSG((hwndCtl), LB_RESETCONTENT, 0L, 0L))
  897. #define ListBox_AddString(hwndCtl, lpsz) ((int)(DWORD)SNDMSG((hwndCtl), LB_ADDSTRING, 0L, (LPARAM)(LPCTSTR)(lpsz)))
  898. #define ListBox_InsertString(hwndCtl, index, lpsz) ((int)(DWORD)SNDMSG((hwndCtl), LB_INSERTSTRING, (WPARAM)(int)(index), (LPARAM)(LPCTSTR)(lpsz)))
  899. #define ListBox_AddItemData(hwndCtl, data) ((int)(DWORD)SNDMSG((hwndCtl), LB_ADDSTRING, 0L, (LPARAM)(data)))
  900. #define ListBox_InsertItemData(hwndCtl, index, data) ((int)(DWORD)SNDMSG((hwndCtl), LB_INSERTSTRING, (WPARAM)(int)(index), (LPARAM)(data)))
  901. #define ListBox_DeleteString(hwndCtl, index) ((int)(DWORD)SNDMSG((hwndCtl), LB_DELETESTRING, (WPARAM)(int)(index), 0L))
  902. #define ListBox_GetTextLen(hwndCtl, index) ((int)(DWORD)SNDMSG((hwndCtl), LB_GETTEXTLEN, (WPARAM)(int)(index), 0L))
  903. #define ListBox_GetText(hwndCtl, index, lpszBuffer) ((int)(DWORD)SNDMSG((hwndCtl), LB_GETTEXT, (WPARAM)(int)(index), (LPARAM)(LPCTSTR)(lpszBuffer)))
  904. #define ListBox_GetItemData(hwndCtl, index) ((LRESULT)(ULONG_PTR)SNDMSG((hwndCtl), LB_GETITEMDATA, (WPARAM)(int)(index), 0L))
  905. #define ListBox_SetItemData(hwndCtl, index, data) ((int)(DWORD)SNDMSG((hwndCtl), LB_SETITEMDATA, (WPARAM)(int)(index), (LPARAM)(data)))
  906. #if (WINVER >= 0x030a)
  907. #define ListBox_FindString(hwndCtl, indexStart, lpszFind) ((int)(DWORD)SNDMSG((hwndCtl), LB_FINDSTRING, (WPARAM)(int)(indexStart), (LPARAM)(LPCTSTR)(lpszFind)))
  908. #define ListBox_FindItemData(hwndCtl, indexStart, data) ((int)(DWORD)SNDMSG((hwndCtl), LB_FINDSTRING, (WPARAM)(int)(indexStart), (LPARAM)(data)))
  909. #define ListBox_SetSel(hwndCtl, fSelect, index) ((int)(DWORD)SNDMSG((hwndCtl), LB_SETSEL, (WPARAM)(BOOL)(fSelect), (LPARAM)(index)))
  910. #define ListBox_SelItemRange(hwndCtl, fSelect, first, last) ((int)(DWORD)SNDMSG((hwndCtl), LB_SELITEMRANGE, (WPARAM)(BOOL)(fSelect), MAKELPARAM((first), (last))))
  911. #define ListBox_GetCurSel(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), LB_GETCURSEL, 0L, 0L))
  912. #define ListBox_SetCurSel(hwndCtl, index) ((int)(DWORD)SNDMSG((hwndCtl), LB_SETCURSEL, (WPARAM)(int)(index), 0L))
  913. #define ListBox_SelectString(hwndCtl, indexStart, lpszFind) ((int)(DWORD)SNDMSG((hwndCtl), LB_SELECTSTRING, (WPARAM)(int)(indexStart), (LPARAM)(LPCTSTR)(lpszFind)))
  914. #define ListBox_SelectItemData(hwndCtl, indexStart, data) ((int)(DWORD)SNDMSG((hwndCtl), LB_SELECTSTRING, (WPARAM)(int)(indexStart), (LPARAM)(data)))
  915. #define ListBox_GetSel(hwndCtl, index) ((int)(DWORD)SNDMSG((hwndCtl), LB_GETSEL, (WPARAM)(int)(index), 0L))
  916. #define ListBox_GetSelCount(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), LB_GETSELCOUNT, 0L, 0L))
  917. #define ListBox_GetTopIndex(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), LB_GETTOPINDEX, 0L, 0L))
  918. #define ListBox_GetSelItems(hwndCtl, cItems, lpItems) ((int)(DWORD)SNDMSG((hwndCtl), LB_GETSELITEMS, (WPARAM)(int)(cItems), (LPARAM)(int *)(lpItems)))
  919. #define ListBox_SetTopIndex(hwndCtl, indexTop) ((int)(DWORD)SNDMSG((hwndCtl), LB_SETTOPINDEX, (WPARAM)(int)(indexTop), 0L))
  920. #define ListBox_SetColumnWidth(hwndCtl, cxColumn) ((void)SNDMSG((hwndCtl), LB_SETCOLUMNWIDTH, (WPARAM)(int)(cxColumn), 0L))
  921. #define ListBox_GetHorizontalExtent(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), LB_GETHORIZONTALEXTENT, 0L, 0L))
  922. #define ListBox_SetHorizontalExtent(hwndCtl, cxExtent) ((void)SNDMSG((hwndCtl), LB_SETHORIZONTALEXTENT, (WPARAM)(int)(cxExtent), 0L))
  923. #define ListBox_SetTabStops(hwndCtl, cTabs, lpTabs) ((BOOL)(DWORD)SNDMSG((hwndCtl), LB_SETTABSTOPS, (WPARAM)(int)(cTabs), (LPARAM)(int *)(lpTabs)))
  924. #define ListBox_GetItemRect(hwndCtl, index, lprc) ((int)(DWORD)SNDMSG((hwndCtl), LB_GETITEMRECT, (WPARAM)(int)(index), (LPARAM)(RECT *)(lprc)))
  925. #define ListBox_SetCaretIndex(hwndCtl, index) ((int)(DWORD)SNDMSG((hwndCtl), LB_SETCARETINDEX, (WPARAM)(int)(index), 0L))
  926. #define ListBox_GetCaretIndex(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), LB_GETCARETINDEX, 0L, 0L))
  927. #define ListBox_FindStringExact(hwndCtl, indexStart, lpszFind) ((int)(DWORD)SNDMSG((hwndCtl), LB_FINDSTRINGEXACT, (WPARAM)(int)(indexStart), (LPARAM)(LPCTSTR)(lpszFind)))
  928. #define ListBox_SetItemHeight(hwndCtl, index, cy) ((int)(DWORD)SNDMSG((hwndCtl), LB_SETITEMHEIGHT, (WPARAM)(int)(index), MAKELPARAM((cy), 0)))
  929. #define ListBox_GetItemHeight(hwndCtl, index) ((int)(DWORD)SNDMSG((hwndCtl), LB_GETITEMHEIGHT, (WPARAM)(int)(index), 0L))
  930. #endif /* WINVER >= 0x030a */
  931. #define ListBox_Dir(hwndCtl, attrs, lpszFileSpec) ((int)(DWORD)SNDMSG((hwndCtl), LB_DIR, (WPARAM)(UINT)(attrs), (LPARAM)(LPCTSTR)(lpszFileSpec)))
  932. /****** ComboBox control message APIs ****************************************/
  933. #define ComboBox_Enable(hwndCtl, fEnable) EnableWindow((hwndCtl), (fEnable))
  934. #define ComboBox_GetText(hwndCtl, lpch, cchMax) GetWindowText((hwndCtl), (lpch), (cchMax))
  935. #define ComboBox_GetTextLength(hwndCtl) GetWindowTextLength(hwndCtl)
  936. #define ComboBox_SetText(hwndCtl, lpsz) SetWindowText((hwndCtl), (lpsz))
  937. #define ComboBox_LimitText(hwndCtl, cchLimit) ((int)(DWORD)SNDMSG((hwndCtl), CB_LIMITTEXT, (WPARAM)(int)(cchLimit), 0L))
  938. #define ComboBox_GetEditSel(hwndCtl) ((DWORD)SNDMSG((hwndCtl), CB_GETEDITSEL, 0L, 0L))
  939. #define ComboBox_SetEditSel(hwndCtl, ichStart, ichEnd) ((int)(DWORD)SNDMSG((hwndCtl), CB_SETEDITSEL, 0L, MAKELPARAM((ichStart), (ichEnd))))
  940. #define ComboBox_GetCount(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), CB_GETCOUNT, 0L, 0L))
  941. #define ComboBox_ResetContent(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), CB_RESETCONTENT, 0L, 0L))
  942. #define ComboBox_AddString(hwndCtl, lpsz) ((int)(DWORD)SNDMSG((hwndCtl), CB_ADDSTRING, 0L, (LPARAM)(LPCTSTR)(lpsz)))
  943. #define ComboBox_InsertString(hwndCtl, index, lpsz) ((int)(DWORD)SNDMSG((hwndCtl), CB_INSERTSTRING, (WPARAM)(int)(index), (LPARAM)(LPCTSTR)(lpsz)))
  944. #define ComboBox_AddItemData(hwndCtl, data) ((int)(DWORD)SNDMSG((hwndCtl), CB_ADDSTRING, 0L, (LPARAM)(data)))
  945. #define ComboBox_InsertItemData(hwndCtl, index, data) ((int)(DWORD)SNDMSG((hwndCtl), CB_INSERTSTRING, (WPARAM)(int)(index), (LPARAM)(data)))
  946. #define ComboBox_DeleteString(hwndCtl, index) ((int)(DWORD)SNDMSG((hwndCtl), CB_DELETESTRING, (WPARAM)(int)(index), 0L))
  947. #define ComboBox_GetLBTextLen(hwndCtl, index) ((int)(DWORD)SNDMSG((hwndCtl), CB_GETLBTEXTLEN, (WPARAM)(int)(index), 0L))
  948. #define ComboBox_GetLBText(hwndCtl, index, lpszBuffer) ((int)(DWORD)SNDMSG((hwndCtl), CB_GETLBTEXT, (WPARAM)(int)(index), (LPARAM)(LPCTSTR)(lpszBuffer)))
  949. #define ComboBox_GetItemData(hwndCtl, index) ((LRESULT)(ULONG_PTR)SNDMSG((hwndCtl), CB_GETITEMDATA, (WPARAM)(int)(index), 0L))
  950. #define ComboBox_SetItemData(hwndCtl, index, data) ((int)(DWORD)SNDMSG((hwndCtl), CB_SETITEMDATA, (WPARAM)(int)(index), (LPARAM)(data)))
  951. #define ComboBox_FindString(hwndCtl, indexStart, lpszFind) ((int)(DWORD)SNDMSG((hwndCtl), CB_FINDSTRING, (WPARAM)(int)(indexStart), (LPARAM)(LPCTSTR)(lpszFind)))
  952. #define ComboBox_FindItemData(hwndCtl, indexStart, data) ((int)(DWORD)SNDMSG((hwndCtl), CB_FINDSTRING, (WPARAM)(int)(indexStart), (LPARAM)(data)))
  953. #define ComboBox_GetCurSel(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), CB_GETCURSEL, 0L, 0L))
  954. #define ComboBox_SetCurSel(hwndCtl, index) ((int)(DWORD)SNDMSG((hwndCtl), CB_SETCURSEL, (WPARAM)(int)(index), 0L))
  955. #define ComboBox_SelectString(hwndCtl, indexStart, lpszSelect) ((int)(DWORD)SNDMSG((hwndCtl), CB_SELECTSTRING, (WPARAM)(int)(indexStart), (LPARAM)(LPCTSTR)(lpszSelect)))
  956. #define ComboBox_SelectItemData(hwndCtl, indexStart, data) ((int)(DWORD)SNDMSG((hwndCtl), CB_SELECTSTRING, (WPARAM)(int)(indexStart), (LPARAM)(data)))
  957. #define ComboBox_Dir(hwndCtl, attrs, lpszFileSpec) ((int)(DWORD)SNDMSG((hwndCtl), CB_DIR, (WPARAM)(UINT)(attrs), (LPARAM)(LPCTSTR)(lpszFileSpec)))
  958. #define ComboBox_ShowDropdown(hwndCtl, fShow) ((BOOL)(DWORD)SNDMSG((hwndCtl), CB_SHOWDROPDOWN, (WPARAM)(BOOL)(fShow), 0L))
  959. #if (WINVER >= 0x030a)
  960. #define ComboBox_FindStringExact(hwndCtl, indexStart, lpszFind) ((int)(DWORD)SNDMSG((hwndCtl), CB_FINDSTRINGEXACT, (WPARAM)(int)(indexStart), (LPARAM)(LPCTSTR)(lpszFind)))
  961. #define ComboBox_GetDroppedState(hwndCtl) ((BOOL)(DWORD)SNDMSG((hwndCtl), CB_GETDROPPEDSTATE, 0L, 0L))
  962. #define ComboBox_GetDroppedControlRect(hwndCtl, lprc) ((void)SNDMSG((hwndCtl), CB_GETDROPPEDCONTROLRECT, 0L, (LPARAM)(RECT *)(lprc)))
  963. #define ComboBox_GetItemHeight(hwndCtl) ((int)(DWORD)SNDMSG((hwndCtl), CB_GETITEMHEIGHT, 0L, 0L))
  964. #define ComboBox_SetItemHeight(hwndCtl, index, cyItem) ((int)(DWORD)SNDMSG((hwndCtl), CB_SETITEMHEIGHT, (WPARAM)(int)(index), (LPARAM)(int)cyItem))
  965. #define ComboBox_GetExtendedUI(hwndCtl) ((UINT)(DWORD)SNDMSG((hwndCtl), CB_GETEXTENDEDUI, 0L, 0L))
  966. #define ComboBox_SetExtendedUI(hwndCtl, flags) ((int)(DWORD)SNDMSG((hwndCtl), CB_SETEXTENDEDUI, (WPARAM)(UINT)(flags), 0L))
  967. #endif /* WINVER >= 0x030a */
  968. /****** Alternate porting layer macros ****************************************/
  969. /* USER MESSAGES: */
  970. #define GET_WPARAM(wp, lp) (wp)
  971. #define GET_LPARAM(wp, lp) (lp)
  972. #define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
  973. #define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
  974. #define GET_WM_ACTIVATE_STATE(wp, lp) LOWORD(wp)
  975. #define GET_WM_ACTIVATE_FMINIMIZED(wp, lp) (BOOL)HIWORD(wp)
  976. #define GET_WM_ACTIVATE_HWND(wp, lp) (HWND)(lp)
  977. #define GET_WM_ACTIVATE_MPS(s, fmin, hwnd) \
  978. (WPARAM)MAKELONG((s), (fmin)), (LPARAM)(hwnd)
  979. #define GET_WM_CHARTOITEM_CHAR(wp, lp) (TCHAR)LOWORD(wp)
  980. #define GET_WM_CHARTOITEM_POS(wp, lp) HIWORD(wp)
  981. #define GET_WM_CHARTOITEM_HWND(wp, lp) (HWND)(lp)
  982. #define GET_WM_CHARTOITEM_MPS(ch, pos, hwnd) \
  983. (WPARAM)MAKELONG((pos), (ch)), (LPARAM)(hwnd)
  984. #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
  985. #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
  986. #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
  987. #define GET_WM_COMMAND_MPS(id, hwnd, cmd) \
  988. (WPARAM)MAKELONG(id, cmd), (LPARAM)(hwnd)
  989. #define WM_CTLCOLOR 0x0019
  990. #define GET_WM_CTLCOLOR_HDC(wp, lp, msg) (HDC)(wp)
  991. #define GET_WM_CTLCOLOR_HWND(wp, lp, msg) (HWND)(lp)
  992. #define GET_WM_CTLCOLOR_TYPE(wp, lp, msg) (WORD)(msg - WM_CTLCOLORMSGBOX)
  993. #define GET_WM_CTLCOLOR_MSG(type) (WORD)(WM_CTLCOLORMSGBOX+(type))
  994. #define GET_WM_CTLCOLOR_MPS(hdc, hwnd, type) \
  995. (WPARAM)(hdc), (LPARAM)(hwnd)
  996. #define GET_WM_MENUSELECT_CMD(wp, lp) LOWORD(wp)
  997. #define GET_WM_MENUSELECT_FLAGS(wp, lp) (UINT)(int)(short)HIWORD(wp)
  998. #define GET_WM_MENUSELECT_HMENU(wp, lp) (HMENU)(lp)
  999. #define GET_WM_MENUSELECT_MPS(cmd, f, hmenu) \
  1000. (WPARAM)MAKELONG(cmd, f), (LPARAM)(hmenu)
  1001. /* Note: the following are for interpreting MDIclient to MDI child messages. */
  1002. #define GET_WM_MDIACTIVATE_FACTIVATE(hwnd, wp, lp) (lp == (LPARAM)hwnd)
  1003. #define GET_WM_MDIACTIVATE_HWNDDEACT(wp, lp) (HWND)(wp)
  1004. #define GET_WM_MDIACTIVATE_HWNDACTIVATE(wp, lp) (HWND)(lp)
  1005. /* Note: the following is for sending to the MDI client window. */
  1006. #define GET_WM_MDIACTIVATE_MPS(f, hwndD, hwndA)\
  1007. (WPARAM)(hwndA), 0
  1008. #define GET_WM_MDISETMENU_MPS(hmenuF, hmenuW) (WPARAM)hmenuF, (LPARAM)hmenuW
  1009. #define GET_WM_MENUCHAR_CHAR(wp, lp) (TCHAR)LOWORD(wp)
  1010. #define GET_WM_MENUCHAR_HMENU(wp, lp) (HMENU)(lp)
  1011. #define GET_WM_MENUCHAR_FMENU(wp, lp) (BOOL)HIWORD(wp)
  1012. #define GET_WM_MENUCHAR_MPS(ch, hmenu, f) \
  1013. (WPARAM)MAKELONG(ch, f), (LPARAM)(hmenu)
  1014. #define GET_WM_PARENTNOTIFY_MSG(wp, lp) LOWORD(wp)
  1015. #define GET_WM_PARENTNOTIFY_ID(wp, lp) HIWORD(wp)
  1016. #define GET_WM_PARENTNOTIFY_HWNDCHILD(wp, lp) (HWND)(lp)
  1017. #define GET_WM_PARENTNOTIFY_X(wp, lp) (int)(short)LOWORD(lp)
  1018. #define GET_WM_PARENTNOTIFY_Y(wp, lp) (int)(short)HIWORD(lp)
  1019. #define GET_WM_PARENTNOTIFY_MPS(msg, id, hwnd) \
  1020. (WPARAM)MAKELONG(id, msg), (LPARAM)(hwnd)
  1021. #define GET_WM_PARENTNOTIFY2_MPS(msg, x, y) \
  1022. (WPARAM)MAKELONG(0, msg), MAKELONG(x, y)
  1023. #define GET_WM_VKEYTOITEM_CODE(wp, lp) (int)(short)LOWORD(wp)
  1024. #define GET_WM_VKEYTOITEM_ITEM(wp, lp) HIWORD(wp)
  1025. #define GET_WM_VKEYTOITEM_HWND(wp, lp) (HWND)(lp)
  1026. #define GET_WM_VKEYTOITEM_MPS(code, item, hwnd) \
  1027. (WPARAM)MAKELONG(item, code), (LPARAM)(hwnd)
  1028. #define GET_EM_SETSEL_START(wp, lp) (INT)(wp)
  1029. #define GET_EM_SETSEL_END(wp, lp) (lp)
  1030. #define GET_EM_SETSEL_MPS(iStart, iEnd) \
  1031. (WPARAM)(iStart), (LPARAM)(iEnd)
  1032. #define GET_EM_LINESCROLL_MPS(vert, horz) \
  1033. (WPARAM)horz, (LPARAM)vert
  1034. #define GET_WM_CHANGECBCHAIN_HWNDNEXT(wp, lp) (HWND)(lp)
  1035. #define GET_WM_HSCROLL_CODE(wp, lp) LOWORD(wp)
  1036. #define GET_WM_HSCROLL_POS(wp, lp) HIWORD(wp)
  1037. #define GET_WM_HSCROLL_HWND(wp, lp) (HWND)(lp)
  1038. #define GET_WM_HSCROLL_MPS(code, pos, hwnd) \
  1039. (WPARAM)MAKELONG(code, pos), (LPARAM)(hwnd)
  1040. #define GET_WM_VSCROLL_CODE(wp, lp) LOWORD(wp)
  1041. #define GET_WM_VSCROLL_POS(wp, lp) HIWORD(wp)
  1042. #define GET_WM_VSCROLL_HWND(wp, lp) (HWND)(lp)
  1043. #define GET_WM_VSCROLL_MPS(code, pos, hwnd) \
  1044. (WPARAM)MAKELONG(code, pos), (LPARAM)(hwnd)
  1045. /****** C runtime porting macros ****************************************/
  1046. #define _ncalloc calloc
  1047. #define _nexpand _expand
  1048. #define _ffree free
  1049. #define _fmalloc malloc
  1050. #define _fmemccpy _memccpy
  1051. #define _fmemchr memchr
  1052. #define _fmemcmp memcmp
  1053. #define _fmemcpy memcpy
  1054. #define _fmemicmp _memicmp
  1055. #define _fmemmove memmove
  1056. #define _fmemset memset
  1057. #define _fmsize _msize
  1058. #define _frealloc realloc
  1059. #define _fstrcat strcat
  1060. #define _fstrchr strchr
  1061. #define _fstrcmp strcmp
  1062. #define _fstrcpy strcpy
  1063. #define _fstrcspn strcspn
  1064. #define _fstrdup _strdup
  1065. #define _fstricmp _stricmp
  1066. #define _fstrlen strlen
  1067. #define _fstrlwr _strlwr
  1068. #define _fstrncat strncat
  1069. #define _fstrncmp strncmp
  1070. #define _fstrncpy strncpy
  1071. #define _fstrnicmp _strnicmp
  1072. #define _fstrnset _strnset
  1073. #define _fstrpbrk strpbrk
  1074. #define _fstrrchr strrchr
  1075. #define _fstrrev _strrev
  1076. #define _fstrset _strset
  1077. #define _fstrspn strspn
  1078. #define _fstrstr strstr
  1079. #define _fstrtok strtok
  1080. #define _fstrupr _strupr
  1081. #define _nfree free
  1082. #define _nmalloc malloc
  1083. #define _nmsize _msize
  1084. #define _nrealloc realloc
  1085. #define _nstrdup _strdup
  1086. #define hmemcpy MoveMemory
  1087. #ifndef DECLARE_HANDLE32
  1088. #define DECLARE_HANDLE32 DECLARE_HANDLE
  1089. #endif
  1090. #ifdef __cplusplus
  1091. } /* End of extern "C" { */
  1092. #endif /* __cplusplus */
  1093. #endif /* !_INC_WINDOWSX */