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