VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/windowsx.h@ 33223

Last change on this file since 33223 was 16477, checked in by vboxsync, 16 years ago

LGPL disclaimer by filemuncher

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette