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