Fixed definition of the RtlMemory functions. Use macros internally and
[wine.git] / include / windowsx.h
blobc28b3c213842fccf182cb6992aabd467fb40181d
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 */
19 #define GET_WM_VSCROLL_CODE(wp, lp) LOWORD(wp)
20 #define GET_WM_VSCROLL_POS(wp, lp) HIWORD(wp)
21 #define GET_WM_VSCROLL_HWND(wp, lp) (HWND)(lp)
22 #define GET_WM_VSCROLL_MPS(code, pos, hwnd) (WPARAM)MAKELONG(code, pos), (LONG)(hwnd)
25 #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
26 #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
27 #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
28 #define GET_WM_COMMAND_MPS(id, hwnd, cmd) (WPARAM)MAKELONG(id, cmd), (LONG)(hwnd)
30 #define WM_CTLCOLOR 0x0019
32 #define GET_WM_CTLCOLOR_HDC(wp, lp, msg) (HDC)(wp)
33 #define GET_WM_CTLCOLOR_HWND(wp, lp, msg) (HWND)(lp)
34 #define GET_WM_CTLCOLOR_TYPE(wp, lp, msg) (WORD)(msg - WM_CTLCOLORMSGBOX)
35 #define GET_WM_CTLCOLOR_MSG(type) (WORD)(WM_CTLCOLORMSGBOX+(type))
36 #define GET_WM_CTLCOLOR_MPS(hdc, hwnd, type) (WPARAM)(hdc), (LONG)(hwnd)
38 #define GET_WM_VKEYTOITEM_CODE(wp, lp) (int)(short)LOWORD(wp)
39 #define GET_WM_VKEYTOITEM_ITEM(wp, lp) HIWORD(wp)
40 #define GET_WM_VKEYTOITEM_HWND(wp, lp) (HWND)(lp)
41 #define GET_WM_VKEYTOITEM_MPS(code, item, hwnd) (WPARAM)MAKELONG(item, code), (LONG)(hwnd)
43 /****** KERNEL Macro APIs ******************************************************/
45 #define GetInstanceModule(hInst) (GetModuleHandle((LPCSTR)MAKELP(0, hInst)))
46 #define GlobalPtrHandle(lp) ((HGLOBAL)LOWORD(GlobalHandle(SELECTOROF(lp))))
47 #define GlobalLockPtr(lp) ((BOOL)SELECTOROF(GlobalLock(GlobalPtrHandle(lp))))
48 #define GlobalUnlockPtr(lp) (GlobalUnlock(GlobalPtrHandle(lp)))
49 #define GlobalAllocPtr(flags,cb) (GlobalLock(GlobalAlloc((flags), (cb))))
50 #define GlobalReAllocPtr(lp, cbNew, flags) (GlobalUnlockPtr(lp), \
51 GlobalLock(GlobalReAlloc(GlobalPtrHandle(lp) , (cbNew), (flags))))
52 #define GlobalFreePtr(lp) (GlobalUnlockPtr(lp), (BOOL)GlobalFree(GlobalPtrHandle(lp)))
54 /****** USER Macro APIs ******************************************************/
56 #define GetWindowInstance(hwnd) ((HMODULE)GetWindowLong(hwnd, GWL_HINSTANCE))
58 #define GetWindowStyle(hwnd) ((DWORD)GetWindowLong(hwnd, GWL_STYLE))
59 #define GetWindowExStyle(hwnd) ((DWORD)GetWindowLong(hwnd, GWL_EXSTYLE))
61 #define GetWindowOwner(hwnd) GetWindow(hwnd, GW_OWNER)
63 #define GetFirstChild(hwnd) GetTopWindow(hwnd)
64 #define GetFirstSibling(hwnd) GetWindow(hwnd, GW_HWNDFIRST)
65 #define GetLastSibling(hwnd) GetWindow(hwnd, GW_HWNDLAST)
66 #define GetNextSibling(hwnd) GetWindow(hwnd, GW_HWNDNEXT)
67 #define GetPrevSibling(hwnd) GetWindow(hwnd, GW_HWNDPREV)
69 #define GetWindowID(hwnd) GetDlgCtrlID(hwnd)
71 #define SetWindowRedraw(hwnd, fRedraw) \
72 ((void)SendMessage(hwnd, WM_SETREDRAW, (WPARAM)(BOOL)(fRedraw), 0L))
73 #define SubclassWindow(hwnd, lpfn) \
74 ((WNDPROC)SetWindowLong((hwnd), GWL_WNDPROC, (LPARAM)(WNDPROC)(lpfn)))
76 #define IsMinimized(hwnd) IsIconic(hwnd)
77 #define IsMaximized(hwnd) IsZoomed(hwnd)
78 #define IsRestored(hwnd) ((GetWindowStyle(hwnd) & (WS_MINIMIZE | WS_MAXIMIZE)) == 0L)
79 #define SetWindowFont(hwnd, hfont, fRedraw) \
80 FORWARD_WM_SETFONT((hwnd), (hfont), (fRedraw), SendMessage)
82 #define GetWindowFont(hwnd) FORWARD_WM_GETFONT((hwnd), SendMessage)
84 #define MapWindowRect(hwndFrom, hwndTo, lprc) \
85 MapWindowPoints((hwndFrom), (hwndTo), (POINT *)(lprc), 2)
87 #define IsLButtonDown() (GetKeyState(VK_LBUTTON) < 0)
88 #define IsRButtonDown() (GetKeyState(VK_RBUTTON) < 0)
89 #define IsMButtonDown() (GetKeyState(VK_MBUTTON) < 0)
91 #define SubclassDialog(hwndDlg, lpfn) \
92 ((DLGPROC)SetWindowLong(hwndDlg, DWL_DLGPROC, (LPARAM)(DLGPROC)(lpfn)))
94 #define DeletePen(hpen) DeleteObject((HGDIOBJ)(HPEN)(hpen))
95 #define SelectPen(hdc, hpen) ((HPEN)SelectObject((hdc), (HGDIOBJ)(HPEN)(hpen)))
96 #define GetStockPen(i) ((HPEN)GetStockObject(i))
98 #define DeleteBrush(hbr) DeleteObject((HGDIOBJ)(HBRUSH)(hbr))
99 #define SelectBrush(hdc, hbr) ((HBRUSH)SelectObject((hdc), (HGDIOBJ)(HBRUSH)(hbr)))
100 #define GetStockBrush(i) ((HBRUSH)GetStockObject(i))
102 #define DeletePalette(hpal) DeleteObject((HGDIOBJ)(HPALETTE)(hpal))
104 #define DeleteFont(hfont) DeleteObject((HGDIOBJ)(HFONT)(hfont))
105 #define SelectFont(hdc, hfont) ((HFONT)SelectObject((hdc), (HGDIOBJ)(HFONT) (hfont)))
106 #define GetStockFont(i) ((HFONT)GetStockObject(i))
107 #define DeleteBitmap(hbm) DeleteObject((HGDIOBJ)(HBITMAP)(hbm))
108 #define SelectBitmap(hdc, hbm) ((HBITMAP)SelectObject((hdc), (HGDIOBJ)(HBITMAP)(hbm)))
109 #define InsetRect(lprc, dx, dy) InflateRect((lprc), -(dx), -(dy))
111 /* COMBOBOX Message APIs */
112 #define ComboBox_GetCount(hwndCtl) \
113 ((int)(DWORD)SendMessage((hwndCtl), CB_GETCOUNT, 0L, 0L))
115 #define ComboBox_GetCurSel(hwndCtl) \
116 ((int)(DWORD)SendMessage((hwndCtl), CB_GETCURSEL, 0L, 0L))
118 #define ComboBox_SetCurSel(hwndCtl, index) \
119 ((int)(DWORD)SendMessage((hwndCtl), CB_SETCURSEL, (WPARAM)(int)(index), 0L))
121 #define ComboBox_GetLBTextLen(hwndCtl, index) \
122 ((int)(DWORD)SendMessage((hwndCtl), CB_GETLBTEXTLEN, (WPARAM)(int)(index), 0L))
124 #define ComboBox_DeleteString(hwndCtl, index) \
125 ((int)(DWORD)SendMessage((hwndCtl), CB_DELETESTRING, (WPARAM)(int)(index), 0L))
127 #define ComboBox_FindString(hwndCtl, indexStart, lpszFind) \
128 ((int)(DWORD)SendMessage((hwndCtl), CB_FINDSTRING, (WPARAM)(int)(indexStart), (LPARAM)(LPCTSTR)(lpszFind)))
130 #define ComboBox_ResetContent(hwndCtl) \
131 ((int)(DWORD)SendMessage((hwndCtl), CB_RESETCONTENT, 0L, 0L))
133 #define ComboBox_AddString(hwndCtl, lpsz) \
134 ((int)(DWORD)SendMessage((hwndCtl), CB_ADDSTRING, 0L, (LPARAM)(LPCTSTR)(lpsz)))
135 #define ComboBox_GetLBTextLen(hwndCtl, index) \
136 ((int)(DWORD)SendMessage((hwndCtl), CB_GETLBTEXTLEN, (WPARAM)(int)(index), 0L))
137 #define ComboBox_GetLBText(hwndCtl, index, lpszBuffer) \
138 ((int)(DWORD)SendMessage((hwndCtl), CB_GETLBTEXT, (WPARAM)(int)(index), (LPARAM)(LPCTSTR)(lpszBuffer)))
140 #define ComboBox_GetDroppedState(hwndCtl) \
141 ((BOOL)(DWORD)SendMessage((hwndCtl), CB_GETDROPPEDSTATE, 0L, 0L))
142 #define ComboBox_GetDroppedControlRect(hwndCtl, lprc) \
143 ((void)SendMessage((hwndCtl), CB_GETDROPPEDCONTROLRECT, 0L, (LPARAM)(RECT *)(lprc)))
145 /****** ListBox control message APIs *****************************************/
147 #define ListBox_Enable(hwndCtl, fEnable) EnableWindow((hwndCtl), (fEnable))
148 #define ListBox_GetCount(hwndCtl) \
149 ((int)(DWORD)SendMessage((hwndCtl), LB_GETCOUNT, 0L, 0L))
150 #define ListBox_ResetContent(hwndCtl) \
151 ((BOOL)(DWORD)SendMessage((hwndCtl), LB_RESETCONTENT, 0L, 0L))
153 #define ListBox_GetItemData(hwndCtl, index) \
154 ((LRESULT)(DWORD)SendMessage((hwndCtl), LB_GETITEMDATA, (WPARAM)(int)(index), 0L))
156 #define ListBox_GetCurSel(hwndCtl) \
157 ((int)(DWORD)SendMessage((hwndCtl), LB_GETCURSEL, 0L, 0L))
158 #define ListBox_SetCurSel(hwndCtl, index) \
159 ((int)(DWORD)SendMessage((hwndCtl), LB_SETCURSEL, (WPARAM)(int)(index), 0L))
161 #define ListBox_AddString(hwndCtl, lpsz) \
162 ((int)(DWORD)SendMessage((hwndCtl), LB_ADDSTRING, 0L, (LPARAM)(LPCTSTR)(lpsz)))
163 #define ListBox_InsertString(hwndCtl, index, lpsz) \
164 ((int)(DWORD)SendMessage((hwndCtl), LB_INSERTSTRING, (WPARAM)(int)(index), (LPARAM)(LPCTSTR)(lpsz)))
166 #define ListBox_AddItemData(hwndCtl, data) \
167 ((int)(DWORD)SendMessage((hwndCtl), LB_ADDSTRING, 0L, (LPARAM)(data)))
168 #define ListBox_InsertItemData(hwndCtl, index, data) \
169 ((int)(DWORD)SendMessage((hwndCtl), LB_INSERTSTRING, (WPARAM)(int)(index), (LPARAM)(data)))
171 #define ListBox_FindString(hwndCtl, indexStart, lpszFind) \
172 ((int)(DWORD)SendMessage((hwndCtl), LB_FINDSTRING, (WPARAM)(int)(indexStart), (LPARAM)(LPCTSTR)(lpszFind)))
173 #define ListBox_FindStringExact(hwndCtl, indexStart, lpszFind) \
174 ((int)(DWORD)SendMessage((hwndCtl), LB_FINDSTRINGEXACT, (WPARAM)(int)(indexStart), (LPARAM)(LPCTSTR)(lpszFind)))
176 #define Edit_LineFromChar(hwndCtl, ich) \
177 ((int)(DWORD)SendMessage((hwndCtl), EM_LINEFROMCHAR, (WPARAM)(int)(ich), 0L))
178 #define Edit_LineIndex(hwndCtl, line) \
179 ((int)(DWORD)SendMessage((hwndCtl), EM_LINEINDEX, (WPARAM)(int)(line), 0L))
180 #define Edit_LineLength(hwndCtl, line) \
181 ((int)(DWORD)SendMessage((hwndCtl), EM_LINELENGTH, (WPARAM)(int)(line), 0L))
183 /****** Edit control message APIs ********************************************/
185 #define Edit_SetSel(hwndCtl, ichStart, ichEnd) \
186 ((void)SendMessage((hwndCtl), EM_SETSEL, (ichStart), (ichEnd)))
188 #define Edit_GetText(hwndCtl, lpch, cchMax) GetWindowText((hwndCtl), (lpch), (cchMax))
189 #define Edit_GetTextLength(hwndCtl) GetWindowTextLength(hwndCtl)
190 #define Edit_SetText(hwndCtl, lpsz) SetWindowText((hwndCtl), (lpsz))
192 #define Edit_GetModify(hwndCtl) \
193 ((BOOL)(DWORD)SendMessage((hwndCtl), EM_GETMODIFY, 0L, 0L))
194 #define Edit_SetModify(hwndCtl, fModified) \
195 ((void)SendMessage((hwndCtl), EM_SETMODIFY, (WPARAM)(UINT)(fModified), 0L))
199 /****** Message crackers ****************************************************/
201 #define HANDLE_MSG(hwnd, message, fn) \
202 case (message): return HANDLE_##message((hwnd), (wParam), (lParam), (fn))
204 /* void Cls_OnCompacting(HWND hwnd, UINT compactRatio) */
205 #define HANDLE_WM_COMPACTING(hwnd, wParam, lParam, fn) \
206 ((fn)((hwnd), (UINT)(wParam)), 0L)
207 #define FORWARD_WM_COMPACTING(hwnd, compactRatio, fn) \
208 (void)(fn)((hwnd), WM_COMPACTING, (WPARAM)(UINT)(compactRatio), 0L)
210 /* void Cls_OnWinIniChange(HWND hwnd, LPCTSTR lpszSectionName) */
211 #define HANDLE_WM_WININICHANGE(hwnd, wParam, lParam, fn) \
212 ((fn)((hwnd), (LPCTSTR)(lParam)), 0L)
213 #define FORWARD_WM_WININICHANGE(hwnd, lpszSectionName, fn) \
214 (void)(fn)((hwnd), WM_WININICHANGE, 0L, (LPARAM)(LPCTSTR)(lpszSectionName))
216 /* void Cls_OnSysColorChange(HWND hwnd) */
217 #define HANDLE_WM_SYSCOLORCHANGE(hwnd, wParam, lParam, fn) \
218 ((fn)(hwnd), 0L)
219 #define FORWARD_WM_SYSCOLORCHANGE(hwnd, fn) \
220 (void)(fn)((hwnd), WM_SYSCOLORCHANGE, 0L, 0L)
222 /* BOOL Cls_OnQueryNewPalette(HWND hwnd) */
223 #define HANDLE_WM_QUERYNEWPALETTE(hwnd, wParam, lParam, fn) \
224 MAKELRESULT((BOOL)(fn)(hwnd), 0L)
225 #define FORWARD_WM_QUERYNEWPALETTE(hwnd, fn) \
226 (BOOL)(DWORD)(fn)((hwnd), WM_QUERYNEWPALETTE, 0L, 0L)
228 /* void Cls_OnPaletteIsChanging(HWND hwnd, HWND hwndPaletteChange) */
229 #define HANDLE_WM_PALETTEISCHANGING(hwnd, wParam, lParam, fn) \
230 ((fn)((hwnd), (HWND)(wParam)), 0L)
231 #define FORWARD_WM_PALETTEISCHANGING(hwnd, hwndPaletteChange, fn) \
232 (void)(fn)((hwnd), WM_PALETTEISCHANGING, (WPARAM)(HWND)(hwndPaletteChange), 0L)
234 /* void Cls_OnPaletteChanged(HWND hwnd, HWND hwndPaletteChange) */
235 #define HANDLE_WM_PALETTECHANGED(hwnd, wParam, lParam, fn) \
236 ((fn)((hwnd), (HWND)(wParam)), 0L)
237 #define FORWARD_WM_PALETTECHANGED(hwnd, hwndPaletteChange, fn) \
238 (void)(fn)((hwnd), WM_PALETTECHANGED, (WPARAM)(HWND)(hwndPaletteChange), 0L)
240 /* void Cls_OnFontChange(HWND hwnd) */
241 #define HANDLE_WM_FONTCHANGE(hwnd, wParam, lParam, fn) \
242 ((fn)(hwnd), 0L)
243 #define FORWARD_WM_FONTCHANGE(hwnd, fn) \
244 (void)(fn)((hwnd), WM_FONTCHANGE, 0L, 0L)
246 /* void Cls_OnSpoolerStatus(HWND hwnd, UINT status, int cJobInQueue) */
247 #define HANDLE_WM_SPOOLERSTATUS(hwnd, wParam, lParam, fn) \
248 ((fn)((hwnd), (UINT)(wParam), (int)(short)LOWORD(lParam)), 0L)
249 #define FORWARD_WM_SPOOLERSTATUS(hwnd, status, cJobInQueue, fn) \
250 (void)(fn)((hwnd), WM_SPOOLERSTATUS, (WPARAM)(status), MAKELPARAM((cJobInQueue), 0))
252 /* void Cls_OnDevModeChange(HWND hwnd, LPCTSTR lpszDeviceName) */
253 #define HANDLE_WM_DEVMODECHANGE(hwnd, wParam, lParam, fn) \
254 ((fn)((hwnd), (LPCTSTR)(lParam)), 0L)
255 #define FORWARD_WM_DEVMODECHANGE(hwnd, lpszDeviceName, fn) \
256 (void)(fn)((hwnd), WM_DEVMODECHANGE, 0L, (LPARAM)(LPCTSTR)(lpszDeviceName))
258 /* void Cls_OnTimeChange(HWND hwnd) */
259 #define HANDLE_WM_TIMECHANGE(hwnd, wParam, lParam, fn) \
260 ((fn)(hwnd), 0L)
261 #define FORWARD_WM_TIMECHANGE(hwnd, fn) \
262 (void)(fn)((hwnd), WM_TIMECHANGE, 0L, 0L)
264 /* void Cls_OnPower(HWND hwnd, int code) */
265 #define HANDLE_WM_POWER(hwnd, wParam, lParam, fn) \
266 ((fn)((hwnd), (int)(wParam)), 0L)
267 #define FORWARD_WM_POWER(hwnd, code, fn) \
268 (void)(fn)((hwnd), WM_POWER, (WPARAM)(int)(code), 0L)
270 /* BOOL Cls_OnQueryEndSession(HWND hwnd) */
271 #define HANDLE_WM_QUERYENDSESSION(hwnd, wParam, lParam, fn) \
272 MAKELRESULT((BOOL)(fn)(hwnd), 0L)
273 #define FORWARD_WM_QUERYENDSESSION(hwnd, fn) \
274 (BOOL)(DWORD)(fn)((hwnd), WM_QUERYENDSESSION, 0L, 0L)
276 /* void Cls_OnEndSession(HWND hwnd, BOOL fEnding) */
277 #define HANDLE_WM_ENDSESSION(hwnd, wParam, lParam, fn) \
278 ((fn)((hwnd), (BOOL)(wParam)), 0L)
279 #define FORWARD_WM_ENDSESSION(hwnd, fEnding, fn) \
280 (void)(fn)((hwnd), WM_ENDSESSION, (WPARAM)(BOOL)(fEnding), 0L)
282 /* void Cls_OnQuit(HWND hwnd, int exitCode) */
283 #define HANDLE_WM_QUIT(hwnd, wParam, lParam, fn) \
284 ((fn)((hwnd), (int)(wParam)), 0L)
285 #define FORWARD_WM_QUIT(hwnd, exitCode, fn) \
286 (void)(fn)((hwnd), WM_QUIT, (WPARAM)(exitCode), 0L)
288 /* This message is in Windows 3.1 only */
289 /* void Cls_OnSystemError(HWND hwnd, int errCode) */
290 #define HANDLE_WM_SYSTEMERROR(hwnd, wParam, lParam, fn) 0L
291 #define FORWARD_WM_SYSTEMERROR(hwnd, errCode, fn) 0L
293 /* BOOL Cls_OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct) */
294 #define HANDLE_WM_CREATE(hwnd, wParam, lParam, fn) \
295 ((fn)((hwnd), (LPCREATESTRUCT)(lParam)) ? 0L : (LRESULT)-1L)
296 #define FORWARD_WM_CREATE(hwnd, lpCreateStruct, fn) \
297 (BOOL)(DWORD)(fn)((hwnd), WM_CREATE, 0L, (LPARAM)(LPCREATESTRUCT)(lpCreateStruct))
299 /* BOOL Cls_OnNCCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct) */
300 #define HANDLE_WM_NCCREATE(hwnd, wParam, lParam, fn) \
301 (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (LPCREATESTRUCT)(lParam))
302 #define FORWARD_WM_NCCREATE(hwnd, lpCreateStruct, fn) \
303 (BOOL)(DWORD)(fn)((hwnd), WM_NCCREATE, 0L, (LPARAM)(LPCREATESTRUCT)(lpCreateStruct))
305 /* void Cls_OnDestroy(HWND hwnd) */
306 #define HANDLE_WM_DESTROY(hwnd, wParam, lParam, fn) \
307 ((fn)(hwnd), 0L)
308 #define FORWARD_WM_DESTROY(hwnd, fn) \
309 (void)(fn)((hwnd), WM_DESTROY, 0L, 0L)
311 /* void Cls_OnNCDestroy(HWND hwnd) */
312 #define HANDLE_WM_NCDESTROY(hwnd, wParam, lParam, fn) \
313 ((fn)(hwnd), 0L)
314 #define FORWARD_WM_NCDESTROY(hwnd, fn) \
315 (void)(fn)((hwnd), WM_NCDESTROY, 0L, 0L)
317 /* void Cls_OnShowWindow(HWND hwnd, BOOL fShow, UINT status) */
318 #define HANDLE_WM_SHOWWINDOW(hwnd, wParam, lParam, fn) \
319 ((fn)((hwnd), (BOOL)(wParam), (UINT)(lParam)), 0L)
320 #define FORWARD_WM_SHOWWINDOW(hwnd, fShow, status, fn) \
321 (void)(fn)((hwnd), WM_SHOWWINDOW, (WPARAM)(BOOL)(fShow), (LPARAM)(UINT)(status))
323 /* void Cls_OnSetRedraw(HWND hwnd, BOOL fRedraw) */
324 #define HANDLE_WM_SETREDRAW(hwnd, wParam, lParam, fn) \
325 ((fn)((hwnd), (BOOL)(wParam)), 0L)
326 #define FORWARD_WM_SETREDRAW(hwnd, fRedraw, fn) \
327 (void)(fn)((hwnd), WM_SETREDRAW, (WPARAM)(BOOL)(fRedraw), 0L)
329 /* void Cls_OnEnable(HWND hwnd, BOOL fEnable) */
330 #define HANDLE_WM_ENABLE(hwnd, wParam, lParam, fn) \
331 ((fn)((hwnd), (BOOL)(wParam)), 0L)
332 #define FORWARD_WM_ENABLE(hwnd, fEnable, fn) \
333 (void)(fn)((hwnd), WM_ENABLE, (WPARAM)(BOOL)(fEnable), 0L)
335 /* void Cls_OnSetText(HWND hwnd, LPCTSTR lpszText) */
336 #define HANDLE_WM_SETTEXT(hwnd, wParam, lParam, fn) \
337 ((fn)((hwnd), (LPCTSTR)(lParam)), 0L)
338 #define FORWARD_WM_SETTEXT(hwnd, lpszText, fn) \
339 (void)(fn)((hwnd), WM_SETTEXT, 0L, (LPARAM)(LPCTSTR)(lpszText))
341 /* INT Cls_OnGetText(HWND hwnd, int cchTextMax, LPTSTR lpszText) */
342 #define HANDLE_WM_GETTEXT(hwnd, wParam, lParam, fn) \
343 (LRESULT)(DWORD)(int)(fn)((hwnd), (int)(wParam), (LPTSTR)(lParam))
344 #define FORWARD_WM_GETTEXT(hwnd, cchTextMax, lpszText, fn) \
345 (int)(DWORD)(fn)((hwnd), WM_GETTEXT, (WPARAM)(int)(cchTextMax), (LPARAM)(LPTSTR)(lpszText))
347 /* INT Cls_OnGetTextLength(HWND hwnd) */
348 #define HANDLE_WM_GETTEXTLENGTH(hwnd, wParam, lParam, fn) \
349 (LRESULT)(DWORD)(int)(fn)(hwnd)
350 #define FORWARD_WM_GETTEXTLENGTH(hwnd, fn) \
351 (int)(DWORD)(fn)((hwnd), WM_GETTEXTLENGTH, 0L, 0L)
353 /* BOOL Cls_OnWindowPosChanging(HWND hwnd, LPWINDOWPOS lpwpos) */
354 #define HANDLE_WM_WINDOWPOSCHANGING(hwnd, wParam, lParam, fn) \
355 (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (LPWINDOWPOS)(lParam))
356 #define FORWARD_WM_WINDOWPOSCHANGING(hwnd, lpwpos, fn) \
357 (BOOL)(DWORD)(fn)((hwnd), WM_WINDOWPOSCHANGING, 0L, (LPARAM)(LPWINDOWPOS)(lpwpos))
359 /* void Cls_OnWindowPosChanged(HWND hwnd, const LPWINDOWPOS lpwpos) */
360 #define HANDLE_WM_WINDOWPOSCHANGED(hwnd, wParam, lParam, fn) \
361 ((fn)((hwnd), (const LPWINDOWPOS)(lParam)), 0L)
362 #define FORWARD_WM_WINDOWPOSCHANGED(hwnd, lpwpos, fn) \
363 (void)(fn)((hwnd), WM_WINDOWPOSCHANGED, 0L, (LPARAM)(const LPWINDOWPOS)(lpwpos))
365 /* void Cls_OnMove(HWND hwnd, int x, int y) */
366 #define HANDLE_WM_MOVE(hwnd, wParam, lParam, fn) \
367 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)), 0L)
368 #define FORWARD_WM_MOVE(hwnd, x, y, fn) \
369 (void)(fn)((hwnd), WM_MOVE, 0L, MAKELPARAM((x), (y)))
371 /* void Cls_OnSize(HWND hwnd, UINT state, int cx, int cy) */
372 #define HANDLE_WM_SIZE(hwnd, wParam, lParam, fn) \
373 ((fn)((hwnd), (UINT)(wParam), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)), 0L)
374 #define FORWARD_WM_SIZE(hwnd, state, cx, cy, fn) \
375 (void)(fn)((hwnd), WM_SIZE, (WPARAM)(UINT)(state), MAKELPARAM((cx), (cy)))
377 /* void Cls_OnClose(HWND hwnd) */
378 #define HANDLE_WM_CLOSE(hwnd, wParam, lParam, fn) \
379 ((fn)(hwnd), 0L)
380 #define FORWARD_WM_CLOSE(hwnd, fn) \
381 (void)(fn)((hwnd), WM_CLOSE, 0L, 0L)
383 /* BOOL Cls_OnQueryOpen(HWND hwnd) */
384 #define HANDLE_WM_QUERYOPEN(hwnd, wParam, lParam, fn) \
385 MAKELRESULT((BOOL)(fn)(hwnd), 0L)
386 #define FORWARD_WM_QUERYOPEN(hwnd, fn) \
387 (BOOL)(DWORD)(fn)((hwnd), WM_QUERYOPEN, 0L, 0L)
389 /* void Cls_OnPaint(HWND hwnd) */
390 #define HANDLE_WM_PAINT(hwnd, wParam, lParam, fn) \
391 ((fn)(hwnd), 0L)
392 #define FORWARD_WM_PAINT(hwnd, fn) \
393 (void)(fn)((hwnd), WM_PAINT, 0L, 0L)
395 /* BOOL Cls_OnEraseBkgnd(HWND hwnd, HDC hdc) */
396 #define HANDLE_WM_ERASEBKGND(hwnd, wParam, lParam, fn) \
397 (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (HDC)(wParam))
398 #define FORWARD_WM_ERASEBKGND(hwnd, hdc, fn) \
399 (BOOL)(DWORD)(fn)((hwnd), WM_ERASEBKGND, (WPARAM)(HDC)(hdc), 0L)
401 /* BOOL Cls_OnIconEraseBkgnd(HWND hwnd, HDC hdc) */
402 #define HANDLE_WM_ICONERASEBKGND(hwnd, wParam, lParam, fn) \
403 (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (HDC)(wParam))
404 #define FORWARD_WM_ICONERASEBKGND(hwnd, hdc, fn) \
405 (BOOL)(DWORD)(fn)((hwnd), WM_ICONERASEBKGND, (WPARAM)(HDC)(hdc), 0L)
407 /* void Cls_OnNCPaint(HWND hwnd, HRGN hrgn) */
408 #define HANDLE_WM_NCPAINT(hwnd, wParam, lParam, fn) \
409 ((fn)((hwnd), (HRGN)(wParam)), 0L)
410 #define FORWARD_WM_NCPAINT(hwnd, hrgn, fn) \
411 (void)(fn)((hwnd), WM_NCPAINT, (WPARAM)(HRGN)(hrgn), 0L)
413 /* UINT Cls_OnNCCalcSize(HWND hwnd, BOOL fCalcValidRects, NCCALCSIZE_PARAMS * lpcsp) */
414 #define HANDLE_WM_NCCALCSIZE(hwnd, wParam, lParam, fn) \
415 (LRESULT)(DWORD)(UINT)(fn)((hwnd), (BOOL)(0), (NCCALCSIZE_PARAMS *)(lParam))
416 #define FORWARD_WM_NCCALCSIZE(hwnd, fCalcValidRects, lpcsp, fn) \
417 (UINT)(DWORD)(fn)((hwnd), WM_NCCALCSIZE, 0L, (LPARAM)(NCCALCSIZE_PARAMS *)(lpcsp))
419 /* HICON Cls_OnQueryDragIcon(HWND hwnd) */
420 #define HANDLE_WM_QUERYDRAGICON(hwnd, wParam, lParam, fn) \
421 (LRESULT)(DWORD)(UINT)(fn)(hwnd)
422 #define FORWARD_WM_QUERYDRAGICON(hwnd, fn) \
423 (HICON)(UINT)(DWORD)(fn)((hwnd), WM_QUERYDRAGICON, 0L, 0L)
425 /* void Cls_OnDropFiles(HWND hwnd, HDROP hdrop) */
426 #define HANDLE_WM_DROPFILES(hwnd, wParam, lParam, fn) \
427 ((fn)((hwnd), (HDROP)(wParam)), 0L)
428 #define FORWARD_WM_DROPFILES(hwnd, hdrop, fn) \
429 (void)(fn)((hwnd), WM_DROPFILES, (WPARAM)(HDROP)(hdrop), 0L)
431 /* void Cls_OnActivate(HWND hwnd, UINT state, HWND hwndActDeact, BOOL fMinimized) */
432 #define HANDLE_WM_ACTIVATE(hwnd, wParam, lParam, fn) \
433 ((fn)((hwnd), (UINT)LOWORD(wParam), (HWND)(lParam), (BOOL)HIWORD(wParam)), 0L)
434 #define FORWARD_WM_ACTIVATE(hwnd, state, hwndActDeact, fMinimized, fn) \
435 (void)(fn)((hwnd), WM_ACTIVATE, MAKEWPARAM((state), (fMinimized)), (LPARAM)(HWND)(hwndActDeact))
437 /* void Cls_OnActivateApp(HWND hwnd, BOOL fActivate, DWORD dwThreadId) */
438 #define HANDLE_WM_ACTIVATEAPP(hwnd, wParam, lParam, fn) \
439 ((fn)((hwnd), (BOOL)(wParam), (DWORD)(lParam)), 0L)
440 #define FORWARD_WM_ACTIVATEAPP(hwnd, fActivate, dwThreadId, fn) \
441 (void)(fn)((hwnd), WM_ACTIVATEAPP, (WPARAM)(BOOL)(fActivate), (LPARAM)(dwThreadId))
443 /* BOOL Cls_OnNCActivate(HWND hwnd, BOOL fActive, HWND hwndActDeact, BOOL fMinimized) */
444 #define HANDLE_WM_NCACTIVATE(hwnd, wParam, lParam, fn) \
445 (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (BOOL)(wParam), 0L, 0L)
446 #define FORWARD_WM_NCACTIVATE(hwnd, fActive, hwndActDeact, fMinimized, fn) \
447 (BOOL)(DWORD)(fn)((hwnd), WM_NCACTIVATE, (WPARAM)(BOOL)(fActive), 0L)
449 /* void Cls_OnSetFocus(HWND hwnd, HWND hwndOldFocus) */
450 #define HANDLE_WM_SETFOCUS(hwnd, wParam, lParam, fn) \
451 ((fn)((hwnd), (HWND)(wParam)), 0L)
452 #define FORWARD_WM_SETFOCUS(hwnd, hwndOldFocus, fn) \
453 (void)(fn)((hwnd), WM_SETFOCUS, (WPARAM)(HWND)(hwndOldFocus), 0L)
455 /* void Cls_OnKillFocus(HWND hwnd, HWND hwndNewFocus) */
456 #define HANDLE_WM_KILLFOCUS(hwnd, wParam, lParam, fn) \
457 ((fn)((hwnd), (HWND)(wParam)), 0L)
458 #define FORWARD_WM_KILLFOCUS(hwnd, hwndNewFocus, fn) \
459 (void)(fn)((hwnd), WM_KILLFOCUS, (WPARAM)(HWND)(hwndNewFocus), 0L)
461 /* void Cls_OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags) */
462 #define HANDLE_WM_KEYDOWN(hwnd, wParam, lParam, fn) \
463 ((fn)((hwnd), (UINT)(wParam), TRUE, (int)(short)LOWORD(lParam), (UINT)HIWORD(lParam)), 0L)
464 #define FORWARD_WM_KEYDOWN(hwnd, vk, cRepeat, flags, fn) \
465 (void)(fn)((hwnd), WM_KEYDOWN, (WPARAM)(UINT)(vk), MAKELPARAM((cRepeat), (flags)))
467 /* void Cls_OnKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags) */
468 #define HANDLE_WM_KEYUP(hwnd, wParam, lParam, fn) \
469 ((fn)((hwnd), (UINT)(wParam), FALSE, (int)(short)LOWORD(lParam), (UINT)HIWORD(lParam)), 0L)
470 #define FORWARD_WM_KEYUP(hwnd, vk, cRepeat, flags, fn) \
471 (void)(fn)((hwnd), WM_KEYUP, (WPARAM)(UINT)(vk), MAKELPARAM((cRepeat), (flags)))
473 /* void Cls_OnChar(HWND hwnd, TCHAR ch, int cRepeat) */
474 #define HANDLE_WM_CHAR(hwnd, wParam, lParam, fn) \
475 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
476 #define FORWARD_WM_CHAR(hwnd, ch, cRepeat, fn) \
477 (void)(fn)((hwnd), WM_CHAR, (WPARAM)(TCHAR)(ch), MAKELPARAM((cRepeat),0))
479 /* void Cls_OnDeadChar(HWND hwnd, TCHAR ch, int cRepeat) */
480 #define HANDLE_WM_DEADCHAR(hwnd, wParam, lParam, fn) \
481 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
482 #define FORWARD_WM_DEADCHAR(hwnd, ch, cRepeat, fn) \
483 (void)(fn)((hwnd), WM_DEADCHAR, (WPARAM)(TCHAR)(ch), MAKELPARAM((cRepeat),0))
485 /* void Cls_OnSysKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags) */
486 #define HANDLE_WM_SYSKEYDOWN(hwnd, wParam, lParam, fn) \
487 ((fn)((hwnd), (UINT)(wParam), TRUE, (int)(short)LOWORD(lParam), (UINT)HIWORD(lParam)), 0L)
488 #define FORWARD_WM_SYSKEYDOWN(hwnd, vk, cRepeat, flags, fn) \
489 (void)(fn)((hwnd), WM_SYSKEYDOWN, (WPARAM)(UINT)(vk), MAKELPARAM((cRepeat), (flags)))
491 /* void Cls_OnSysKey(HWND hwnd, UINT vk, BOOL fDown, int cRepeat, UINT flags) */
492 #define HANDLE_WM_SYSKEYUP(hwnd, wParam, lParam, fn) \
493 ((fn)((hwnd), (UINT)(wParam), FALSE, (int)(short)LOWORD(lParam), (UINT)HIWORD(lParam)), 0L)
494 #define FORWARD_WM_SYSKEYUP(hwnd, vk, cRepeat, flags, fn) \
495 (void)(fn)((hwnd), WM_SYSKEYUP, (WPARAM)(UINT)(vk), MAKELPARAM((cRepeat), (flags)))
497 /* void Cls_OnSysChar(HWND hwnd, TCHAR ch, int cRepeat) */
498 #define HANDLE_WM_SYSCHAR(hwnd, wParam, lParam, fn) \
499 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
500 #define FORWARD_WM_SYSCHAR(hwnd, ch, cRepeat, fn) \
501 (void)(fn)((hwnd), WM_SYSCHAR, (WPARAM)(TCHAR)(ch), MAKELPARAM((cRepeat), 0))
503 /* void Cls_OnSysDeadChar(HWND hwnd, TCHAR ch, int cRepeat) */
504 #define HANDLE_WM_SYSDEADCHAR(hwnd, wParam, lParam, fn) \
505 ((fn)((hwnd), (TCHAR)(wParam), (int)(short)LOWORD(lParam)), 0L)
506 #define FORWARD_WM_SYSDEADCHAR(hwnd, ch, cRepeat, fn) \
507 (void)(fn)((hwnd), WM_SYSDEADCHAR, (WPARAM)(TCHAR)(ch), MAKELPARAM((cRepeat), 0))
509 /* void Cls_OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags) */
510 #define HANDLE_WM_MOUSEMOVE(hwnd, wParam, lParam, fn) \
511 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
512 #define FORWARD_WM_MOUSEMOVE(hwnd, x, y, keyFlags, fn) \
513 (void)(fn)((hwnd), WM_MOUSEMOVE, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
515 /* void Cls_OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) */
516 #define HANDLE_WM_LBUTTONDOWN(hwnd, wParam, lParam, fn) \
517 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
518 #define FORWARD_WM_LBUTTONDOWN(hwnd, fDoubleClick, x, y, keyFlags, fn) \
519 (void)(fn)((hwnd), (fDoubleClick) ? WM_LBUTTONDBLCLK : WM_LBUTTONDOWN, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
521 /* void Cls_OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) */
522 #define HANDLE_WM_LBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
523 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
525 /* void Cls_OnLButtonUp(HWND hwnd, int x, int y, UINT keyFlags) */
526 #define HANDLE_WM_LBUTTONUP(hwnd, wParam, lParam, fn) \
527 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
528 #define FORWARD_WM_LBUTTONUP(hwnd, x, y, keyFlags, fn) \
529 (void)(fn)((hwnd), WM_LBUTTONUP, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
531 /* void Cls_OnRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) */
532 #define HANDLE_WM_RBUTTONDOWN(hwnd, wParam, lParam, fn) \
533 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
534 #define FORWARD_WM_RBUTTONDOWN(hwnd, fDoubleClick, x, y, keyFlags, fn) \
535 (void)(fn)((hwnd), (fDoubleClick) ? WM_RBUTTONDBLCLK : WM_RBUTTONDOWN, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
537 /* void Cls_OnRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) */
538 #define HANDLE_WM_RBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
539 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
541 /* void Cls_OnRButtonUp(HWND hwnd, int x, int y, UINT flags) */
542 #define HANDLE_WM_RBUTTONUP(hwnd, wParam, lParam, fn) \
543 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
544 #define FORWARD_WM_RBUTTONUP(hwnd, x, y, keyFlags, fn) \
545 (void)(fn)((hwnd), WM_RBUTTONUP, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
547 /* void Cls_OnMButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) */
548 #define HANDLE_WM_MBUTTONDOWN(hwnd, wParam, lParam, fn) \
549 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
550 #define FORWARD_WM_MBUTTONDOWN(hwnd, fDoubleClick, x, y, keyFlags, fn) \
551 (void)(fn)((hwnd), (fDoubleClick) ? WM_MBUTTONDBLCLK : WM_MBUTTONDOWN, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
553 /* void Cls_OnMButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags) */
554 #define HANDLE_WM_MBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
555 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
557 /* void Cls_OnMButtonUp(HWND hwnd, int x, int y, UINT flags) */
558 #define HANDLE_WM_MBUTTONUP(hwnd, wParam, lParam, fn) \
559 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
560 #define FORWARD_WM_MBUTTONUP(hwnd, x, y, keyFlags, fn) \
561 (void)(fn)((hwnd), WM_MBUTTONUP, (WPARAM)(UINT)(keyFlags), MAKELPARAM((x), (y)))
563 /* void Cls_OnNCMouseMove(HWND hwnd, int x, int y, UINT codeHitTest) */
564 #define HANDLE_WM_NCMOUSEMOVE(hwnd, wParam, lParam, fn) \
565 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
566 #define FORWARD_WM_NCMOUSEMOVE(hwnd, x, y, codeHitTest, fn) \
567 (void)(fn)((hwnd), WM_NCMOUSEMOVE, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)))
569 /* void Cls_OnNCLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT codeHitTest) */
570 #define HANDLE_WM_NCLBUTTONDOWN(hwnd, wParam, lParam, fn) \
571 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
572 #define FORWARD_WM_NCLBUTTONDOWN(hwnd, fDoubleClick, x, y, codeHitTest, fn) \
573 (void)(fn)((hwnd), (fDoubleClick) ? WM_NCLBUTTONDBLCLK : WM_NCLBUTTONDOWN, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)))
575 /* void Cls_OnNCLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT codeHitTest) */
576 #define HANDLE_WM_NCLBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
577 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
579 /* void Cls_OnNCLButtonUp(HWND hwnd, int x, int y, UINT codeHitTest) */
580 #define HANDLE_WM_NCLBUTTONUP(hwnd, wParam, lParam, fn) \
581 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
582 #define FORWARD_WM_NCLBUTTONUP(hwnd, x, y, codeHitTest, fn) \
583 (void)(fn)((hwnd), WM_NCLBUTTONUP, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)))
585 /* void Cls_OnNCRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT codeHitTest) */
586 #define HANDLE_WM_NCRBUTTONDOWN(hwnd, wParam, lParam, fn) \
587 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
588 #define FORWARD_WM_NCRBUTTONDOWN(hwnd, fDoubleClick, x, y, codeHitTest, fn) \
589 (void)(fn)((hwnd), (fDoubleClick) ? WM_NCRBUTTONDBLCLK : WM_NCRBUTTONDOWN, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)) )
591 /* void Cls_OnNCRButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT codeHitTest) */
592 #define HANDLE_WM_NCRBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
593 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
595 /* void Cls_OnNCRButtonUp(HWND hwnd, int x, int y, UINT codeHitTest) */
596 #define HANDLE_WM_NCRBUTTONUP(hwnd, wParam, lParam, fn) \
597 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
598 #define FORWARD_WM_NCRBUTTONUP(hwnd, x, y, codeHitTest, fn) \
599 (void)(fn)((hwnd), WM_NCRBUTTONUP, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)) )
601 /* void Cls_OnNCMButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT codeHitTest) */
602 #define HANDLE_WM_NCMBUTTONDOWN(hwnd, wParam, lParam, fn) \
603 ((fn)((hwnd), FALSE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
604 #define FORWARD_WM_NCMBUTTONDOWN(hwnd, fDoubleClick, x, y, codeHitTest, fn) \
605 (void)(fn)((hwnd), (fDoubleClick) ? WM_NCMBUTTONDBLCLK : WM_NCMBUTTONDOWN, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)) )
607 /* void Cls_OnNCMButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT codeHitTest) */
608 #define HANDLE_WM_NCMBUTTONDBLCLK(hwnd, wParam, lParam, fn) \
609 ((fn)((hwnd), TRUE, (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
611 /* void Cls_OnNCMButtonUp(HWND hwnd, int x, int y, UINT codeHitTest) */
612 #define HANDLE_WM_NCMBUTTONUP(hwnd, wParam, lParam, fn) \
613 ((fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam), (UINT)(wParam)), 0L)
614 #define FORWARD_WM_NCMBUTTONUP(hwnd, x, y, codeHitTest, fn) \
615 (void)(fn)((hwnd), WM_NCMBUTTONUP, (WPARAM)(UINT)(codeHitTest), MAKELPARAM((x), (y)) )
617 /* int Cls_OnMouseActivate(HWND hwnd, HWND hwndTopLevel, UINT codeHitTest, UINT msg) */
618 #define HANDLE_WM_MOUSEACTIVATE(hwnd, wParam, lParam, fn) \
619 (LRESULT)(DWORD)(int)(fn)((hwnd), (HWND)(wParam), (UINT)LOWORD(lParam), (UINT)HIWORD(lParam))
620 #define FORWARD_WM_MOUSEACTIVATE(hwnd, hwndTopLevel, codeHitTest, msg, fn) \
621 (int)(DWORD)(fn)((hwnd), WM_MOUSEACTIVATE, (WPARAM)(HWND)(hwndTopLevel), MAKELPARAM((codeHitTest), (msg)))
623 /* void Cls_OnCancelMode(HWND hwnd) */
624 #define HANDLE_WM_CANCELMODE(hwnd, wParam, lParam, fn) ((fn)(hwnd), 0L)
625 #define FORWARD_WM_CANCELMODE(hwnd, fn) (void)(fn)((hwnd), WM_CANCELMODE, 0L, 0L)
627 /* void Cls_OnInitMenu(HWND hwnd, HMENU hMenu) */
628 #define HANDLE_WM_INITMENU(hwnd, wParam, lParam, fn) \
629 ((fn)((hwnd), (HMENU)(wParam)), 0L)
630 #define FORWARD_WM_INITMENU(hwnd, hMenu, fn) \
631 (void)(fn)((hwnd), WM_INITMENU, (WPARAM)(HMENU)(hMenu), 0L)
633 /* void Cls_OnMenuSelect(HWND hwnd, HMENU hmenu, int item, HMENU hmenuPopup, UINT flags) */
634 #define HANDLE_WM_MENUSELECT(hwnd, wParam, lParam, fn) \
635 ((fn)((hwnd), (HMENU)(lParam), \
636 (HIWORD(wParam) & MF_POPUP) ? 0L : (int)(LOWORD(wParam)), \
637 (HIWORD(wParam) & MF_POPUP) ? GetSubMenu((HMENU)lParam, LOWORD(wParam)) : 0L, \
638 (UINT)(((short)HIWORD(wParam) == -1) ? 0xFFFFFFFF : HIWORD(wParam))), 0L)
639 #define FORWARD_WM_MENUSELECT(hwnd, hmenu, item, hmenuPopup, flags, fn) \
640 (void)(fn)((hwnd), WM_MENUSELECT, MAKEWPARAM((item), (flags)), (LPARAM)(HMENU)((hmenu) ? (hmenu) : (hmenuPopup)))
642 /* DWORD Cls_OnMenuChar(HWND hwnd, UINT ch, UINT flags, HMENU hmenu) */
643 #define HANDLE_WM_MENUCHAR(hwnd, wParam, lParam, fn) \
644 (LRESULT)(DWORD)(fn)((hwnd), (UINT)(LOWORD(wParam)), (UINT)HIWORD(wParam), (HMENU)(lParam))
645 #define FORWARD_WM_MENUCHAR(hwnd, ch, flags, hmenu, fn) \
646 (DWORD)(fn)((hwnd), WM_MENUCHAR, MAKEWPARAM(flags, (WORD)(ch)), (LPARAM)(HMENU)(hmenu))
648 /* void Cls_OnHScroll(HWND hwnd, HWND hwndCtl, UINT code, int pos) */
649 #define HANDLE_WM_HSCROLL(hwnd, wParam, lParam, fn) \
650 ((fn)((hwnd), (HWND)(lParam), (UINT)(LOWORD(wParam)), (int)(short)HIWORD(wParam)), 0L)
651 #define FORWARD_WM_HSCROLL(hwnd, hwndCtl, code, pos, fn) \
652 (void)(fn)((hwnd), WM_HSCROLL, MAKEWPARAM((UINT)(int)(code),(UINT)(int)(pos)), (LPARAM)(UINT)(hwndCtl))
654 /* void Cls_OnVScroll(HWND hwnd, HWND hwndCtl, UINT code, int pos) */
655 #define HANDLE_WM_VSCROLL(hwnd, wParam, lParam, fn) \
656 ((fn)((hwnd), (HWND)(lParam), (UINT)(LOWORD(wParam)), (int)(short)HIWORD(wParam)), 0L)
657 #define FORWARD_WM_VSCROLL(hwnd, hwndCtl, code, pos, fn) \
658 (void)(fn)((hwnd), WM_VSCROLL, MAKEWPARAM((UINT)(int)(code), (UINT)(int)(pos)), (LPARAM)(HWND)(hwndCtl))
660 /* void Cls_OnCut(HWND hwnd) */
661 #define HANDLE_WM_CUT(hwnd, wParam, lParam, fn) ((fn)(hwnd), 0L)
662 #define FORWARD_WM_CUT(hwnd, fn) (void)(fn)((hwnd), WM_CUT, 0L, 0L)
664 /* void Cls_OnCopy(HWND hwnd) */
665 #define HANDLE_WM_COPY(hwnd, wParam, lParam, fn) ((fn)(hwnd), 0L)
666 #define FORWARD_WM_COPY(hwnd, fn) (void)(fn)((hwnd), WM_COPY, 0L, 0L)
668 /* void Cls_OnPaste(HWND hwnd) */
669 #define HANDLE_WM_PASTE(hwnd, wParam, lParam, fn) ((fn)(hwnd), 0L)
670 #define FORWARD_WM_PASTE(hwnd, fn) (void)(fn)((hwnd), WM_PASTE, 0L, 0L)
672 /* void Cls_OnClear(HWND hwnd) */
673 #define HANDLE_WM_CLEAR(hwnd, wParam, lParam, fn) ((fn)(hwnd), 0L)
674 #define FORWARD_WM_CLEAR(hwnd, fn) (void)(fn)((hwnd), WM_CLEAR, 0L, 0L)
676 /* void Cls_OnUndo(HWND hwnd) */
677 #define HANDLE_WM_UNDO(hwnd, wParam, lParam, fn) ((fn)(hwnd), 0L)
678 #define FORWARD_WM_UNDO(hwnd, fn) (void)(fn)((hwnd), WM_UNDO, 0L, 0L)
680 /* HANDLE Cls_OnRenderFormat(HWND hwnd, UINT fmt) */
681 #define HANDLE_WM_RENDERFORMAT(hwnd, wParam, lParam, fn) \
682 (LRESULT)(DWORD)(UINT)(HANDLE)(fn)((hwnd), (UINT)(wParam))
683 #define FORWARD_WM_RENDERFORMAT(hwnd, fmt, fn) \
684 (HANDLE)(UINT)(DWORD)(fn)((hwnd), WM_RENDERFORMAT, (WPARAM)(UINT)(fmt), 0L)
686 /* void Cls_OnRenderAllFormats(HWND hwnd) */
687 #define HANDLE_WM_RENDERALLFORMATS(hwnd, wParam, lParam, fn) ((fn)(hwnd), 0L)
688 #define FORWARD_WM_RENDERALLFORMATS(hwnd, fn) (void)(fn)((hwnd), WM_RENDERALLFORMATS, 0L, 0L)
690 /* void Cls_OnDestroyClipboard(HWND hwnd) */
691 #define HANDLE_WM_DESTROYCLIPBOARD(hwnd, wParam, lParam, fn) ((fn)(hwnd), 0L)
692 #define FORWARD_WM_DESTROYCLIPBOARD(hwnd, fn) (void)(fn)((hwnd), WM_DESTROYCLIPBOARD, 0L, 0L)
694 /* void Cls_OnDrawClipboard(HWND hwnd) */
695 #define HANDLE_WM_DRAWCLIPBOARD(hwnd, wParam, lParam, fn) ((fn)(hwnd), 0L)
696 #define FORWARD_WM_DRAWCLIPBOARD(hwnd, fn) (void)(fn)((hwnd), WM_DRAWCLIPBOARD, 0L, 0L)
698 /* void Cls_OnPaintClipboard(HWND hwnd, HWND hwndCBViewer, const LPPAINTSTRUCT lpPaintStruct) */
699 #define HANDLE_WM_PAINTCLIPBOARD(hwnd, wParam, lParam, fn) \
700 ((fn)((hwnd), (HWND)(wParam), (const LPPAINTSTRUCT)GlobalLock((HGLOBAL)(lParam))), GlobalUnlock((HGLOBAL)(lParam)), 0L)
701 #define FORWARD_WM_PAINTCLIPBOARD(hwnd, hwndCBViewer, lpPaintStruct, fn) \
702 (void)(fn)((hwnd), WM_PAINTCLIPBOARD, (WPARAM)(HWND)(hwndCBViewer), (LPARAM)(LPPAINTSTRUCT)(lpPaintStruct))
704 /* void Cls_OnSizeClipboard(HWND hwnd, HWND hwndCBViewer, const LPRECT lprc) */
705 #define HANDLE_WM_SIZECLIPBOARD(hwnd, wParam, lParam, fn) \
706 ((fn)((hwnd), (HWND)(wParam), (const LPRECT)GlobalLock((HGLOBAL)(lParam))), GlobalUnlock((HGLOBAL)(lParam)), 0L)
707 #define FORWARD_WM_SIZECLIPBOARD(hwnd, hwndCBViewer, lprc, fn) \
708 (void)(fn)((hwnd), WM_SIZECLIPBOARD, (WPARAM)(HWND)(hwndCBViewer), (LPARAM)(LPRECT)(lprc))
710 /* void Cls_OnVScrollClipboard(HWND hwnd, HWND hwndCBViewer, UINT code, int pos) */
711 #define HANDLE_WM_VSCROLLCLIPBOARD(hwnd, wParam, lParam, fn) \
712 ((fn)((hwnd), (HWND)(wParam), (UINT)LOWORD(lParam), (int)(short)HIWORD(lParam)), 0L)
713 #define FORWARD_WM_VSCROLLCLIPBOARD(hwnd, hwndCBViewer, code, pos, fn) \
714 (void)(fn)((hwnd), WM_VSCROLLCLIPBOARD, (WPARAM)(HWND)(hwndCBViewer), MAKELPARAM((code), (pos)))
716 /* void Cls_OnHScrollClipboard(HWND hwnd, HWND hwndCBViewer, UINT code, int pos) */
717 #define HANDLE_WM_HSCROLLCLIPBOARD(hwnd, wParam, lParam, fn) \
718 ((fn)((hwnd), (HWND)(wParam), (UINT)LOWORD(lParam), (int)(short)HIWORD(lParam)), 0L)
719 #define FORWARD_WM_HSCROLLCLIPBOARD(hwnd, hwndCBViewer, code, pos, fn) \
720 (void)(fn)((hwnd), WM_HSCROLLCLIPBOARD, (WPARAM)(HWND)(hwndCBViewer), MAKELPARAM((code), (pos)))
722 /* void Cls_OnAskCBFormatName(HWND hwnd, int cchMax, LPTSTR rgchName) */
723 #define HANDLE_WM_ASKCBFORMATNAME(hwnd, wParam, lParam, fn) \
724 ((fn)((hwnd), (int)(wParam), (LPTSTR)(lParam)), 0L)
725 #define FORWARD_WM_ASKCBFORMATNAME(hwnd, cchMax, rgchName, fn) \
726 (void)(fn)((hwnd), WM_ASKCBFORMATNAME, (WPARAM)(int)(cchMax), (LPARAM)(rgchName))
728 /* void Cls_OnChangeCBChain(HWND hwnd, HWND hwndRemove, HWND hwndNext) */
729 #define HANDLE_WM_CHANGECBCHAIN(hwnd, wParam, lParam, fn) \
730 ((fn)((hwnd), (HWND)(wParam), (HWND)(lParam)), 0L)
731 #define FORWARD_WM_CHANGECBCHAIN(hwnd, hwndRemove, hwndNext, fn) \
732 (void)(fn)((hwnd), WM_CHANGECBCHAIN, (WPARAM)(HWND)(hwndRemove), (LPARAM)(HWND)(hwndNext))
734 /* BOOL Cls_OnSetCursor(HWND hwnd, HWND hwndCursor, UINT codeHitTest, UINT msg) */
735 #define HANDLE_WM_SETCURSOR(hwnd, wParam, lParam, fn) \
736 (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (HWND)(wParam), (UINT)LOWORD(lParam), (UINT)HIWORD(lParam))
737 #define FORWARD_WM_SETCURSOR(hwnd, hwndCursor, codeHitTest, msg, fn) \
738 (BOOL)(DWORD)(fn)((hwnd), WM_SETCURSOR, (WPARAM)(HWND)(hwndCursor), MAKELPARAM((codeHitTest), (msg)))
740 /* void Cls_OnSysCommand(HWND hwnd, UINT cmd, int x, int y) */
741 #define HANDLE_WM_SYSCOMMAND(hwnd, wParam, lParam, fn) \
742 ((fn)((hwnd), (UINT)(wParam), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)), 0L)
743 #define FORWARD_WM_SYSCOMMAND(hwnd, cmd, x, y, fn) \
744 (void)(fn)((hwnd), WM_SYSCOMMAND, (WPARAM)(UINT)(cmd), MAKELPARAM((x), (y)))
746 /* HWND Cls_MDICreate(HWND hwnd, const LPMDICREATESTRUCT lpmcs) */
747 #define HANDLE_WM_MDICREATE(hwnd, wParam, lParam, fn) \
748 (LRESULT)(DWORD)(UINT)(fn)((hwnd), (LPMDICREATESTRUCT)(lParam))
749 #define FORWARD_WM_MDICREATE(hwnd, lpmcs, fn) \
750 (HWND)(UINT)(DWORD)(fn)((hwnd), WM_MDICREATE, 0L, (LPARAM)(LPMDICREATESTRUCT)(lpmcs))
752 /* void Cls_MDIDestroy(HWND hwnd, HWND hwndDestroy) */
753 #define HANDLE_WM_MDIDESTROY(hwnd, wParam, lParam, fn) \
754 ((fn)((hwnd), (HWND)(wParam)), 0L)
755 #define FORWARD_WM_MDIDESTROY(hwnd, hwndDestroy, fn) \
756 (void)(fn)((hwnd), WM_MDIDESTROY, (WPARAM)(hwndDestroy), 0L)
758 /* NOTE: Usable only by MDI client windows */
759 /* void Cls_MDIActivate(HWND hwnd, BOOL fActive, HWND hwndActivate, HWND hwndDeactivate) */
760 #define HANDLE_WM_MDIACTIVATE(hwnd, wParam, lParam, fn) \
761 ((fn)((hwnd), (BOOL)(lParam == (LPARAM)hwnd), (HWND)(lParam), (HWND)(wParam)), 0L)
762 #define FORWARD_WM_MDIACTIVATE(hwnd, fActive, hwndActivate, hwndDeactivate, fn) \
763 (void)(fn)(hwnd, WM_MDIACTIVATE, (WPARAM)(hwndDeactivate), (LPARAM)(hwndActivate))
765 /* void Cls_MDIRestore(HWND hwnd, HWND hwndRestore) */
766 #define HANDLE_WM_MDIRESTORE(hwnd, wParam, lParam, fn) \
767 ((fn)((hwnd), (HWND)(wParam)), 0L)
768 #define FORWARD_WM_MDIRESTORE(hwnd, hwndRestore, fn) \
769 (void)(fn)((hwnd), WM_MDIRESTORE, (WPARAM)(hwndRestore), 0L)
771 /* HWND Cls_MDINext(HWND hwnd, HWND hwndCur, BOOL fPrev) */
772 #define HANDLE_WM_MDINEXT(hwnd, wParam, lParam, fn) \
773 (LRESULT)(HWND)(fn)((hwnd), (HWND)(wParam), (BOOL)lParam)
774 #define FORWARD_WM_MDINEXT(hwnd, hwndCur, fPrev, fn) \
775 (HWND)(UINT)(DWORD)(fn)((hwnd), WM_MDINEXT, (WPARAM)(hwndCur), (LPARAM)(fPrev))
777 /* void Cls_MDIMaximize(HWND hwnd, HWND hwndMaximize) */
778 #define HANDLE_WM_MDIMAXIMIZE(hwnd, wParam, lParam, fn) \
779 ((fn)((hwnd), (HWND)(wParam)), 0L)
780 #define FORWARD_WM_MDIMAXIMIZE(hwnd, hwndMaximize, fn) \
781 (void)(fn)((hwnd), WM_MDIMAXIMIZE, (WPARAM)(hwndMaximize), 0L)
783 /* BOOL Cls_MDITile(HWND hwnd, UINT cmd) */
784 #define HANDLE_WM_MDITILE(hwnd, wParam, lParam, fn) \
785 (LRESULT)(DWORD)(fn)((hwnd), (UINT)(wParam))
786 #define FORWARD_WM_MDITILE(hwnd, cmd, fn) \
787 (BOOL)(DWORD)(fn)((hwnd), WM_MDITILE, (WPARAM)(cmd), 0L)
789 /* BOOL Cls_MDICascade(HWND hwnd, UINT cmd) */
790 #define HANDLE_WM_MDICASCADE(hwnd, wParam, lParam, fn) \
791 (LRESULT)(DWORD)(fn)((hwnd), (UINT)(wParam))
792 #define FORWARD_WM_MDICASCADE(hwnd, cmd, fn) \
793 (BOOL)(DWORD)(fn)((hwnd), WM_MDICASCADE, (WPARAM)(cmd), 0L)
795 /* void Cls_MDIIconArrange(HWND hwnd) */
796 #define HANDLE_WM_MDIICONARRANGE(hwnd, wParam, lParam, fn) \
797 ((fn)(hwnd), 0L)
798 #define FORWARD_WM_MDIICONARRANGE(hwnd, fn) \
799 (void)(fn)((hwnd), WM_MDIICONARRANGE, 0L, 0L)
801 /* HWND Cls_MDIGetActive(HWND hwnd) */
802 #define HANDLE_WM_MDIGETACTIVE(hwnd, wParam, lParam, fn) \
803 (LRESULT)(DWORD)(UINT)(fn)(hwnd)
804 #define FORWARD_WM_MDIGETACTIVE(hwnd, fn) \
805 (HWND)(UINT)(DWORD)(fn)((hwnd), WM_MDIGETACTIVE, 0L, 0L)
807 /* HMENU Cls_MDISetMenu(HWND hwnd, BOOL fRefresh, HMENU hmenuFrame, HMENU hmenuWindow) */
808 #define HANDLE_WM_MDISETMENU(hwnd, wParam, lParam, fn) \
809 (LRESULT)(DWORD)(UINT)(fn)((hwnd), (BOOL)(wParam), (HMENU)(wParam), (HMENU)(lParam))
810 #define FORWARD_WM_MDISETMENU(hwnd, fRefresh, hmenuFrame, hmenuWindow, fn) \
811 (HMENU)(UINT)(DWORD)(fn)((hwnd), WM_MDISETMENU, (WPARAM)((fRefresh) ? (hmenuFrame) : 0), (LPARAM)(hmenuWindow))
813 /* void Cls_OnChildActivate(HWND hwnd) */
814 #define HANDLE_WM_CHILDACTIVATE(hwnd, wParam, lParam, fn) \
815 ((fn)(hwnd), 0L)
816 #define FORWARD_WM_CHILDACTIVATE(hwnd, fn) \
817 (void)(fn)((hwnd), WM_CHILDACTIVATE, 0L, 0L)
819 /* BOOL Cls_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam) */
820 #define HANDLE_WM_INITDIALOG(hwnd, wParam, lParam, fn) \
821 (LRESULT)(DWORD)(UINT)(BOOL)(fn)((hwnd), (HWND)(wParam), lParam)
822 #define FORWARD_WM_INITDIALOG(hwnd, hwndFocus, lParam, fn) \
823 (BOOL)(DWORD)(fn)((hwnd), WM_INITDIALOG, (WPARAM)(HWND)(hwndFocus), (lParam))
825 /* HWND Cls_OnNextDlgCtl(HWND hwnd, HWND hwndSetFocus, BOOL fNext) */
826 #define HANDLE_WM_NEXTDLGCTL(hwnd, wParam, lParam, fn) \
827 (LRESULT)(DWORD)(UINT)(HWND)(fn)((hwnd), (HWND)(wParam), (BOOL)(lParam))
828 #define FORWARD_WM_NEXTDLGCTL(hwnd, hwndSetFocus, fNext, fn) \
829 (HWND)(UINT)(DWORD)(fn)((hwnd), WM_NEXTDLGCTL, (WPARAM)(HWND)(hwndSetFocus), (LPARAM)(fNext))
831 /* void Cls_OnParentNotify(HWND hwnd, UINT msg, HWND hwndChild, int idChild) */
832 #define HANDLE_WM_PARENTNOTIFY(hwnd, wParam, lParam, fn) \
833 ((fn)((hwnd), (UINT)LOWORD(wParam), (HWND)(lParam), (UINT)HIWORD(wParam)), 0L)
834 #define FORWARD_WM_PARENTNOTIFY(hwnd, msg, hwndChild, idChild, fn) \
835 (void)(fn)((hwnd), WM_PARENTNOTIFY, MAKEWPARAM(msg, idChild), (LPARAM)(hwndChild))
837 /* void Cls_OnEnterIdle(HWND hwnd, UINT source, HWND hwndSource) */
838 #define HANDLE_WM_ENTERIDLE(hwnd, wParam, lParam, fn) \
839 ((fn)((hwnd), (UINT)(wParam), (HWND)(lParam)), 0L)
840 #define FORWARD_WM_ENTERIDLE(hwnd, source, hwndSource, fn) \
841 (void)(fn)((hwnd), WM_ENTERIDLE, (WPARAM)(UINT)(source), (LPARAM)(HWND)(hwndSource))
843 /* UINT Cls_OnGetDlgCode(HWND hwnd, LPMSG lpmsg) */
844 #define HANDLE_WM_GETDLGCODE(hwnd, wParam, lParam, fn) \
845 (LRESULT)(DWORD)(UINT)(fn)(hwnd, (LPMSG)(lParam))
846 #define FORWARD_WM_GETDLGCODE(hwnd, lpmsg, fn) \
847 (UINT)(DWORD)(fn)((hwnd), WM_GETDLGCODE, (lpmsg ? lpmsg->wParam : 0), (LPARAM)(LPMSG)(lpmsg))
849 /* HBRUSH Cls_OnCtlColor(HWND hwnd, HDC hdc, HWND hwndChild, int type) */
850 #define HANDLE_WM_CTLCOLORMSGBOX(hwnd, wParam, lParam, fn) \
851 (LRESULT)(DWORD)(UINT)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_MSGBOX)
852 #define FORWARD_WM_CTLCOLORMSGBOX(hwnd, hdc, hwndChild, fn) \
853 (HBRUSH)(UINT)(DWORD)(fn)((hwnd), WM_CTLCOLORMSGBOX, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
855 #define HANDLE_WM_CTLCOLOREDIT(hwnd, wParam, lParam, fn) \
856 (LRESULT)(DWORD)(UINT)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_EDIT)
857 #define FORWARD_WM_CTLCOLOREDIT(hwnd, hdc, hwndChild, fn) \
858 (HBRUSH)(UINT)(DWORD)(fn)((hwnd), WM_CTLCOLOREDIT, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
860 #define HANDLE_WM_CTLCOLORLISTBOX(hwnd, wParam, lParam, fn) \
861 (LRESULT)(DWORD)(UINT)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_LISTBOX)
862 #define FORWARD_WM_CTLCOLORLISTBOX(hwnd, hdc, hwndChild, fn) \
863 (HBRUSH)(UINT)(DWORD)(fn)((hwnd), WM_CTLCOLORLISTBOX, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
865 #define HANDLE_WM_CTLCOLORBTN(hwnd, wParam, lParam, fn) \
866 (LRESULT)(DWORD)(UINT)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_BTN)
867 #define FORWARD_WM_CTLCOLORBTN(hwnd, hdc, hwndChild, fn) \
868 (HBRUSH)(UINT)(DWORD)(fn)((hwnd), WM_CTLCOLORBTN, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
870 #define HANDLE_WM_CTLCOLORDLG(hwnd, wParam, lParam, fn) \
871 (LRESULT)(DWORD)(UINT)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_DLG)
872 #define FORWARD_WM_CTLCOLORDLG(hwnd, hdc, hwndChild, fn) \
873 (HBRUSH)(UINT)(DWORD)(fn)((hwnd), WM_CTLCOLORDLG, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
875 #define HANDLE_WM_CTLCOLORSCROLLBAR(hwnd, wParam, lParam, fn) \
876 (LRESULT)(DWORD)(UINT)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_SCROLLBAR)
877 #define FORWARD_WM_CTLCOLORSCROLLBAR(hwnd, hdc, hwndChild, fn) \
878 (HBRUSH)(UINT)(DWORD)(fn)((hwnd), WM_CTLCOLORSCROLLBAR, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
880 #define HANDLE_WM_CTLCOLORSTATIC(hwnd, wParam, lParam, fn) \
881 (LRESULT)(DWORD)(UINT)(HBRUSH)(fn)((hwnd), (HDC)(wParam), (HWND)(lParam), CTLCOLOR_STATIC)
882 #define FORWARD_WM_CTLCOLORSTATIC(hwnd, hdc, hwndChild, fn) \
883 (HBRUSH)(UINT)(DWORD)(fn)((hwnd), WM_CTLCOLORSTATIC, (WPARAM)(HDC)(hdc), (LPARAM)(HWND)(hwndChild))
885 /* void Cls_OnDeleteItem(HWND hwnd, const DELETEITEMSTRUCT * lpDeleteItem) */
886 #define HANDLE_WM_DELETEITEM(hwnd, wParam, lParam, fn) \
887 ((fn)((hwnd), (const DELETEITEMSTRUCT *)(lParam)), 0L)
888 #define FORWARD_WM_DELETEITEM(hwnd, lpDeleteItem, fn) \
889 (void)(fn)((hwnd), WM_DELETEITEM, (WPARAM)(((const DELETEITEMSTRUCT *)(lpDeleteItem))->CtlID), (LPARAM)(const DELETEITEMSTRUCT *)(lpDeleteItem))
891 /* int Cls_OnCompareItem(HWND hwnd, const COMPAREITEMSTRUCT * lpCompareItem) */
892 #define HANDLE_WM_COMPAREITEM(hwnd, wParam, lParam, fn) \
893 (LRESULT)(DWORD)(int)(fn)((hwnd), (const COMPAREITEMSTRUCT *)(lParam))
894 #define FORWARD_WM_COMPAREITEM(hwnd, lpCompareItem, fn) \
895 (int)(DWORD)(fn)((hwnd), WM_COMPAREITEM, (WPARAM)(((const COMPAREITEMSTRUCT *)(lpCompareItem))->CtlID), (LPARAM)(const COMPAREITEMSTRUCT *)(lpCompareItem))
897 /* int Cls_OnVkeyToItem(HWND hwnd, UINT vk, HWND hwndListbox, int iCaret) */
898 #define HANDLE_WM_VKEYTOITEM(hwnd, wParam, lParam, fn) \
899 (LRESULT)(DWORD)(int)(fn)((hwnd), (UINT)LOWORD(wParam), (HWND)(lParam), (int)(short)HIWORD(wParam))
900 #define FORWARD_WM_VKEYTOITEM(hwnd, vk, hwndListBox, iCaret, fn) \
901 (int)(DWORD)(fn)((hwnd), WM_VKEYTOITEM, MAKEWPARAM((vk), (iCaret)), (LPARAM)(hwndListBox))
903 /* int Cls_OnCharToItem(HWND hwnd, UINT ch, HWND hwndListbox, int iCaret) */
904 #define HANDLE_WM_CHARTOITEM(hwnd, wParam, lParam, fn) \
905 (LRESULT)(DWORD)(int)(fn)((hwnd), (UINT)LOWORD(wParam), (HWND)(lParam), (int)(short)HIWORD(wParam))
906 #define FORWARD_WM_CHARTOITEM(hwnd, ch, hwndListBox, iCaret, fn) \
907 (int)(DWORD)(fn)((hwnd), WM_CHARTOITEM, MAKEWPARAM((UINT)(ch), (UINT)(iCaret)), (LPARAM)(hwndListBox))
909 /* void Cls_OnQueueSync(HWND hwnd) */
910 #define HANDLE_WM_QUEUESYNC(hwnd, wParam, lParam, fn) \
911 ((fn)(hwnd), 0L)
912 #define FORWARD_WM_QUEUESYNC(hwnd, fn) \
913 (void)(fn)((hwnd), WM_QUEUESYNC, 0L, 0L)
914 #if (WINVER >= 0x030a)
915 /* void Cls_OnCommNotify(HWND hwnd, int cid, UINT flags) */
916 #define HANDLE_WM_COMMNOTIFY(hwnd, wParam, lParam, fn) \
917 ((fn)((hwnd), (int)(wParam), (UINT)LOWORD(lParam)), 0L)
918 #define FORWARD_WM_COMMNOTIFY(hwnd, cid, flags, fn) \
919 (void)(fn)((hwnd), WM_COMMNOTIFY, (WPARAM)(cid), MAKELPARAM((flags), 0))
920 #endif
922 /* void Cls_OnDisplayChange(HWND hwnd, UINT bitsPerPixel, UINT cxScreen, UINT cyScreen) */
923 #define HANDLE_WM_DISPLAYCHANGE(hwnd, wParam, lParam, fn) \
924 ((fn)((hwnd), (UINT)(wParam), (UINT)LOWORD(lParam), (UINT)HIWORD(wParam)), 0L)
925 #define FORWARD_WM_DISPLAYCHANGE(hwnd, bitsPerPixel, cxScreen, cyScreen, fn) \
926 (void)(fn)((hwnd), WM_DISPLAYCHANGE, (WPARAM)(UINT)(bitsPerPixel), (LPARAM)MAKELPARAM((UINT)(cxScreen), (UINT)(cyScreen)))
928 /* BOOL Cls_OnDeviceChange(HWND hwnd, UINT uEvent, DWORD dwEventData) */
929 #define HANDLE_WM_DEVICECHANGE(hwnd, wParam, lParam, fn) \
930 (LRESULT)(DWORD)(BOOL)(fn)((hwnd), (UINT)(wParam), (DWORD)(wParam))
931 #define FORWARD_WM_DEVICECHANGE(hwnd, uEvent, dwEventData, fn) \
932 (BOOL)(DWORD)(fn)((hwnd), WM_DEVICECHANGE, (WPARAM)(UINT)(uEvent), (LPARAM)(DWORD)(dwEventData))
934 /* void Cls_OnContextMenu(HWND hwnd, HWND hwndContext, UINT xPos, UINT yPos) */
935 #define HANDLE_WM_CONTEXTMENU(hwnd, wParam, lParam, fn) \
936 ((fn)((hwnd), (HWND)(wParam), (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)), 0L)
937 #define FORWARD_WM_CONTEXTMENU(hwnd, hwndContext, xPos, yPos, fn) \
938 (void)(fn)((hwnd), WM_CONTEXTMENU, (WPARAM)(HWND)(hwndContext), MAKELPARAM((UINT)(xPos), (UINT)(yPos)))
940 /* void Cls_OnMeasureItem(HWND hwnd, MEASUREITEMSTRUCT * lpMeasureItem) */
941 #define HANDLE_WM_MEASUREITEM(hwnd, wParam, lParam, fn) \
942 ((fn)((hwnd), (MEASUREITEMSTRUCT *)(lParam)), 0L)
943 #define FORWARD_WM_MEASUREITEM(hwnd, lpMeasureItem, fn) \
944 (void)(fn)((hwnd), WM_MEASUREITEM, (WPARAM)(((MEASUREITEMSTRUCT *)lpMeasureItem)->CtlID), (LPARAM)(MEASUREITEMSTRUCT *)(lpMeasureItem))
946 /* void Cls_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) */
947 #define HANDLE_WM_COMMAND(hwnd, wParam, lParam, fn) \
948 ((fn)((hwnd), (int)(LOWORD(wParam)), (HWND)(lParam), (UINT)HIWORD(wParam)), 0L)
949 #define FORWARD_WM_COMMAND(hwnd, id, hwndCtl, codeNotify, fn) \
950 (void)(fn)((hwnd), WM_COMMAND, MAKEWPARAM((UINT)(id),(UINT)(codeNotify)), (LPARAM)(HWND)(hwndCtl))
952 /* void Cls_OnTimer(HWND hwnd, UINT id) */
953 #define HANDLE_WM_TIMER(hwnd, wParam, lParam, fn) ((fn)((hwnd), (UINT)(wParam)), 0L)
954 #define FORWARD_WM_TIMER(hwnd, id, fn) (void)(fn)((hwnd), WM_TIMER, (WPARAM)(UINT)(id), 0L)
956 /* void Cls_OnInitMenuPopup(HWND hwnd, HMENU hMenu, UINT item, BOOL fSystemMenu) */
957 #define HANDLE_WM_INITMENUPOPUP(hwnd, wParam, lParam, fn) \
958 ((fn)((hwnd), (HMENU)(wParam), (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam)), 0L)
959 #define FORWARD_WM_INITMENUPOPUP(hwnd, hMenu, item, fSystemMenu, fn) \
960 (void)(fn)((hwnd), WM_INITMENUPOPUP, (WPARAM)(HMENU)(hMenu), MAKELPARAM((item),(fSystemMenu)))
962 /* UINT Cls_OnNCHitTest(HWND hwnd, int x, int y) */
963 #define HANDLE_WM_NCHITTEST(hwnd, wParam, lParam, fn) \
964 (LRESULT)(DWORD)(UINT)(fn)((hwnd), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam))
965 #define FORWARD_WM_NCHITTEST(hwnd, x, y, fn) \
966 (UINT)(DWORD)(fn)((hwnd), WM_NCHITTEST, 0L, MAKELPARAM((x), (y)))
968 /* HFONT Cls_OnGetFont(HWND hwnd) */
969 #define HANDLE_WM_GETFONT(hwnd, wParam, lParam, fn) (LRESULT)(DWORD)(UINT)(HFONT)(fn)(hwnd)
970 #define FORWARD_WM_GETFONT(hwnd, fn) (HFONT)(UINT)(DWORD)(fn)((hwnd), WM_GETFONT, 0L, 0L)
972 /* void Cls_OnSetFont(HWND hwndCtl, HFONT hfont, BOOL fRedraw) */
973 #define HANDLE_WM_SETFONT(hwnd, wParam, lParam, fn) \
974 ((fn)((hwnd), (HFONT)(wParam), (BOOL)(lParam)), 0L)
975 #define FORWARD_WM_SETFONT(hwnd, hfont, fRedraw, fn) \
976 (void)(fn)((hwnd), WM_SETFONT, (WPARAM)(HFONT)(hfont), (LPARAM)(BOOL)(fRedraw))
978 /* void Cls_OnGetMinMaxInfo(HWND hwnd, LPMINMAXINFO lpMinMaxInfo) */
979 #define HANDLE_WM_GETMINMAXINFO(hwnd, wParam, lParam, fn) \
980 ((fn)((hwnd), (LPMINMAXINFO)(lParam)), 0L)
981 #define FORWARD_WM_GETMINMAXINFO(hwnd, lpMinMaxInfo, fn) \
982 (void)(fn)((hwnd), WM_GETMINMAXINFO, 0L, (LPARAM)(LPMINMAXINFO)(lpMinMaxInfo))
984 /* void Cls_OnDrawItem(HWND hwnd, const DRAWITEMSTRUCT lpDrawItem) */
985 #define HANDLE_WM_DRAWITEM(hwnd, wParam, lParam, fn) \
986 ((fn)((hwnd), (const DRAWITEMSTRUCT *)(lParam)), 0L)
987 #define FORWARD_WM_DRAWITEM(hwnd, lpDrawItem, fn) \
988 (void)(fn)((hwnd), WM_DRAWITEM, (WPARAM)(((const DRAWITEMSTRUCT *)lpDrawItem)->CtlID), (LPARAM)(const DRAWITEMSTRUCT *)(lpDrawItem))
991 /****** C runtime porting macros ****************************************/
993 #define _ncalloc calloc
994 #define _nexpand _expand
995 #define _ffree free
996 #define _fmalloc malloc
997 #define _fmemccpy _memccpy
998 #define _fmemchr memchr
999 #define _fmemcmp memcmp
1000 #define _fmemcpy memcpy
1001 #define _fmemicmp _memicmp
1002 #define _fmemmove memmove
1003 #define _fmemset memset
1004 #define _fmsize _msize
1005 #define _frealloc realloc
1006 #define _fstrcat strcat
1007 #define _fstrchr strchr
1008 #define _fstrcmp strcmp
1009 #define _fstrcpy strcpy
1010 #define _fstrcspn strcspn
1011 #define _fstrdup _strdup
1012 #define _fstricmp _stricmp
1013 #define _fstrlen strlen
1014 #define _fstrlwr _strlwr
1015 #define _fstrncat strncat
1016 #define _fstrncmp strncmp
1017 #define _fstrncpy strncpy
1018 #define _fstrnicmp _strnicmp
1019 #define _fstrnset _strnset
1020 #define _fstrpbrk strpbrk
1021 #define _fstrrchr strrchr
1022 #define _fstrrev _strrev
1023 #define _fstrset _strset
1024 #define _fstrspn strspn
1025 #define _fstrstr strstr
1026 #define _fstrtok strtok
1027 #define _fstrupr _strupr
1028 #define _nfree free
1029 #define _nmalloc malloc
1030 #define _nmsize _msize
1031 #define _nrealloc realloc
1032 #define _nstrdup _strdup
1033 #define hmemcpy16 MoveMemory
1035 #ifdef __cplusplus
1037 #endif
1039 #endif