1 // Windows Template Library - WTL version 9.10
2 // Copyright (C) Microsoft Corporation, WTL Team. All rights reserved.
3 //
4 // This file is a part of the Windows Template Library.
5 // The use and distribution terms for this software are covered by the
6 // Microsoft Public License (http://opensource.org/licenses/MS-PL)
7 // which can be found in the file MS-PL.txt at the root folder.
8 
9 #ifndef __ATLCRACK_H__
10 #define __ATLCRACK_H__
11 
12 #pragma once
13 
14 #ifndef __ATLAPP_H__
15 	#error atlcrack.h requires atlapp.h to be included first
16 #endif
17 
18 
19 ///////////////////////////////////////////////////////////////////////////////
20 // Message map macro for cracked handlers
21 
22 // Note about message maps with cracked handlers:
23 // For ATL 3.0, a message map using cracked handlers MUST use BEGIN_MSG_MAP_EX.
24 // For ATL 7.0 or higher, you can use BEGIN_MSG_MAP for CWindowImpl/CDialogImpl derived classes,
25 // but must use BEGIN_MSG_MAP_EX for classes that don't derive from CWindowImpl/CDialogImpl.
26 
27 #define BEGIN_MSG_MAP_EX(theClass) \
28 public: \
29 	BOOL m_bMsgHandled; \
30 	/* "handled" management for cracked handlers */ \
31 	BOOL IsMsgHandled() const \
32 	{ \
33 		return m_bMsgHandled; \
34 	} \
35 	void SetMsgHandled(BOOL bHandled) \
36 	{ \
37 		m_bMsgHandled = bHandled; \
38 	} \
39 	BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0) \
40 	{ \
41 		BOOL bOldMsgHandled = m_bMsgHandled; \
42 		BOOL bRet = _ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, dwMsgMapID); \
43 		m_bMsgHandled = bOldMsgHandled; \
44 		return bRet; \
45 	} \
46 	BOOL _ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID) \
47 	{ \
48 		BOOL bHandled = TRUE; \
49 		(hWnd); \
50 		(uMsg); \
51 		(wParam); \
52 		(lParam); \
53 		(lResult); \
54 		(bHandled); \
55 		switch(dwMsgMapID) \
56 		{ \
57 		case 0:
58 
59 
60 ///////////////////////////////////////////////////////////////////////////////
61 // Standard Windows message macros
62 
63 // int OnCreate(LPCREATESTRUCT lpCreateStruct)
64 #define MSG_WM_CREATE(func) \
65 	if (uMsg == WM_CREATE) \
66 	{ \
67 		SetMsgHandled(TRUE); \
68 		lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \
69 		if(IsMsgHandled()) \
70 			return TRUE; \
71 	}
72 
73 // BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam)
74 #define MSG_WM_INITDIALOG(func) \
75 	if (uMsg == WM_INITDIALOG) \
76 	{ \
77 		SetMsgHandled(TRUE); \
78 		lResult = (LRESULT)func((HWND)wParam, lParam); \
79 		if(IsMsgHandled()) \
80 			return TRUE; \
81 	}
82 
83 // BOOL OnCopyData(CWindow wnd, PCOPYDATASTRUCT pCopyDataStruct)
84 #define MSG_WM_COPYDATA(func) \
85 	if (uMsg == WM_COPYDATA) \
86 	{ \
87 		SetMsgHandled(TRUE); \
88 		lResult = (LRESULT)func((HWND)wParam, (PCOPYDATASTRUCT)lParam); \
89 		if(IsMsgHandled()) \
90 			return TRUE; \
91 	}
92 
93 // void OnDestroy()
94 #define MSG_WM_DESTROY(func) \
95 	if (uMsg == WM_DESTROY) \
96 	{ \
97 		SetMsgHandled(TRUE); \
98 		func(); \
99 		lResult = 0; \
100 		if(IsMsgHandled()) \
101 			return TRUE; \
102 	}
103 
104 // void OnMove(CPoint ptPos)
105 #define MSG_WM_MOVE(func) \
106 	if (uMsg == WM_MOVE) \
107 	{ \
108 		SetMsgHandled(TRUE); \
109 		func(_WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
110 		lResult = 0; \
111 		if(IsMsgHandled()) \
112 			return TRUE; \
113 	}
114 
115 // void OnSize(UINT nType, CSize size)
116 #define MSG_WM_SIZE(func) \
117 	if (uMsg == WM_SIZE) \
118 	{ \
119 		SetMsgHandled(TRUE); \
120 		func((UINT)wParam, _WTYPES_NS::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
121 		lResult = 0; \
122 		if(IsMsgHandled()) \
123 			return TRUE; \
124 	}
125 
126 // void OnActivate(UINT nState, BOOL bMinimized, CWindow wndOther)
127 #define MSG_WM_ACTIVATE(func) \
128 	if (uMsg == WM_ACTIVATE) \
129 	{ \
130 		SetMsgHandled(TRUE); \
131 		func((UINT)LOWORD(wParam), (BOOL)HIWORD(wParam), (HWND)lParam); \
132 		lResult = 0; \
133 		if(IsMsgHandled()) \
134 			return TRUE; \
135 	}
136 
137 // void OnSetFocus(CWindow wndOld)
138 #define MSG_WM_SETFOCUS(func) \
139 	if (uMsg == WM_SETFOCUS) \
140 	{ \
141 		SetMsgHandled(TRUE); \
142 		func((HWND)wParam); \
143 		lResult = 0; \
144 		if(IsMsgHandled()) \
145 			return TRUE; \
146 	}
147 
148 // void OnKillFocus(CWindow wndFocus)
149 #define MSG_WM_KILLFOCUS(func) \
150 	if (uMsg == WM_KILLFOCUS) \
151 	{ \
152 		SetMsgHandled(TRUE); \
153 		func((HWND)wParam); \
154 		lResult = 0; \
155 		if(IsMsgHandled()) \
156 			return TRUE; \
157 	}
158 
159 // void OnEnable(BOOL bEnable)
160 #define MSG_WM_ENABLE(func) \
161 	if (uMsg == WM_ENABLE) \
162 	{ \
163 		SetMsgHandled(TRUE); \
164 		func((BOOL)wParam); \
165 		lResult = 0; \
166 		if(IsMsgHandled()) \
167 			return TRUE; \
168 	}
169 
170 // void OnPaint(CDCHandle dc)
171 #define MSG_WM_PAINT(func) \
172 	if (uMsg == WM_PAINT) \
173 	{ \
174 		SetMsgHandled(TRUE); \
175 		func((HDC)wParam); \
176 		lResult = 0; \
177 		if(IsMsgHandled()) \
178 			return TRUE; \
179 	}
180 
181 // void OnClose()
182 #define MSG_WM_CLOSE(func) \
183 	if (uMsg == WM_CLOSE) \
184 	{ \
185 		SetMsgHandled(TRUE); \
186 		func(); \
187 		lResult = 0; \
188 		if(IsMsgHandled()) \
189 			return TRUE; \
190 	}
191 
192 // BOOL OnQueryEndSession(UINT nSource, UINT uLogOff)
193 #define MSG_WM_QUERYENDSESSION(func) \
194 	if (uMsg == WM_QUERYENDSESSION) \
195 	{ \
196 		SetMsgHandled(TRUE); \
197 		lResult = (LRESULT)func((UINT)wParam, (UINT)lParam); \
198 		if(IsMsgHandled()) \
199 			return TRUE; \
200 	}
201 
202 // BOOL OnQueryOpen()
203 #define MSG_WM_QUERYOPEN(func) \
204 	if (uMsg == WM_QUERYOPEN) \
205 	{ \
206 		SetMsgHandled(TRUE); \
207 		lResult = (LRESULT)func(); \
208 		if(IsMsgHandled()) \
209 			return TRUE; \
210 	}
211 
212 // BOOL OnEraseBkgnd(CDCHandle dc)
213 #define MSG_WM_ERASEBKGND(func) \
214 	if (uMsg == WM_ERASEBKGND) \
215 	{ \
216 		SetMsgHandled(TRUE); \
217 		lResult = (LRESULT)func((HDC)wParam); \
218 		if(IsMsgHandled()) \
219 			return TRUE; \
220 	}
221 
222 // void OnSysColorChange()
223 #define MSG_WM_SYSCOLORCHANGE(func) \
224 	if (uMsg == WM_SYSCOLORCHANGE) \
225 	{ \
226 		SetMsgHandled(TRUE); \
227 		func(); \
228 		lResult = 0; \
229 		if(IsMsgHandled()) \
230 			return TRUE; \
231 	}
232 
233 // void OnEndSession(BOOL bEnding, UINT uLogOff)
234 #define MSG_WM_ENDSESSION(func) \
235 	if (uMsg == WM_ENDSESSION) \
236 	{ \
237 		SetMsgHandled(TRUE); \
238 		func((BOOL)wParam, (UINT)lParam); \
239 		lResult = 0; \
240 		if(IsMsgHandled()) \
241 			return TRUE; \
242 	}
243 
244 // void OnShowWindow(BOOL bShow, UINT nStatus)
245 #define MSG_WM_SHOWWINDOW(func) \
246 	if (uMsg == WM_SHOWWINDOW) \
247 	{ \
248 		SetMsgHandled(TRUE); \
249 		func((BOOL)wParam, (int)lParam); \
250 		lResult = 0; \
251 		if(IsMsgHandled()) \
252 			return TRUE; \
253 	}
254 
255 // HBRUSH OnCtlColorEdit(CDCHandle dc, CEdit edit)
256 #define MSG_WM_CTLCOLOREDIT(func) \
257 	if (uMsg == WM_CTLCOLOREDIT) \
258 	{ \
259 		SetMsgHandled(TRUE); \
260 		lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
261 		if(IsMsgHandled()) \
262 			return TRUE; \
263 	}
264 
265 // HBRUSH OnCtlColorListBox(CDCHandle dc, CListBox listBox)
266 #define MSG_WM_CTLCOLORLISTBOX(func) \
267 	if (uMsg == WM_CTLCOLORLISTBOX) \
268 	{ \
269 		SetMsgHandled(TRUE); \
270 		lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
271 		if(IsMsgHandled()) \
272 			return TRUE; \
273 	}
274 
275 // HBRUSH OnCtlColorBtn(CDCHandle dc, CButton button)
276 #define MSG_WM_CTLCOLORBTN(func) \
277 	if (uMsg == WM_CTLCOLORBTN) \
278 	{ \
279 		SetMsgHandled(TRUE); \
280 		lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
281 		if(IsMsgHandled()) \
282 			return TRUE; \
283 	}
284 
285 // HBRUSH OnCtlColorDlg(CDCHandle dc, CWindow wnd)
286 #define MSG_WM_CTLCOLORDLG(func) \
287 	if (uMsg == WM_CTLCOLORDLG) \
288 	{ \
289 		SetMsgHandled(TRUE); \
290 		lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
291 		if(IsMsgHandled()) \
292 			return TRUE; \
293 	}
294 
295 // HBRUSH OnCtlColorScrollBar(CDCHandle dc, CScrollBar scrollBar)
296 #define MSG_WM_CTLCOLORSCROLLBAR(func) \
297 	if (uMsg == WM_CTLCOLORSCROLLBAR) \
298 	{ \
299 		SetMsgHandled(TRUE); \
300 		lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
301 		if(IsMsgHandled()) \
302 			return TRUE; \
303 	}
304 
305 // HBRUSH OnCtlColorStatic(CDCHandle dc, CStatic wndStatic)
306 #define MSG_WM_CTLCOLORSTATIC(func) \
307 	if (uMsg == WM_CTLCOLORSTATIC) \
308 	{ \
309 		SetMsgHandled(TRUE); \
310 		lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
311 		if(IsMsgHandled()) \
312 			return TRUE; \
313 	}
314 
315 // void OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
316 #define MSG_WM_SETTINGCHANGE(func) \
317 	if (uMsg == WM_SETTINGCHANGE) \
318 	{ \
319 		SetMsgHandled(TRUE); \
320 		func((UINT)wParam, (LPCTSTR)lParam); \
321 		lResult = 0; \
322 		if(IsMsgHandled()) \
323 			return TRUE; \
324 	}
325 
326 // void OnDevModeChange(LPCTSTR lpDeviceName)
327 #define MSG_WM_DEVMODECHANGE(func) \
328 	if (uMsg == WM_DEVMODECHANGE) \
329 	{ \
330 		SetMsgHandled(TRUE); \
331 		func((LPCTSTR)lParam); \
332 		lResult = 0; \
333 		if(IsMsgHandled()) \
334 			return TRUE; \
335 	}
336 
337 // void OnActivateApp(BOOL bActive, DWORD dwThreadID)
338 #define MSG_WM_ACTIVATEAPP(func) \
339 	if (uMsg == WM_ACTIVATEAPP) \
340 	{ \
341 		SetMsgHandled(TRUE); \
342 		func((BOOL)wParam, (DWORD)lParam); \
343 		lResult = 0; \
344 		if(IsMsgHandled()) \
345 			return TRUE; \
346 	}
347 
348 // void OnFontChange()
349 #define MSG_WM_FONTCHANGE(func) \
350 	if (uMsg == WM_FONTCHANGE) \
351 	{ \
352 		SetMsgHandled(TRUE); \
353 		func(); \
354 		lResult = 0; \
355 		if(IsMsgHandled()) \
356 			return TRUE; \
357 	}
358 
359 // void OnTimeChange()
360 #define MSG_WM_TIMECHANGE(func) \
361 	if (uMsg == WM_TIMECHANGE) \
362 	{ \
363 		SetMsgHandled(TRUE); \
364 		func(); \
365 		lResult = 0; \
366 		if(IsMsgHandled()) \
367 			return TRUE; \
368 	}
369 
370 // void OnCancelMode()
371 #define MSG_WM_CANCELMODE(func) \
372 	if (uMsg == WM_CANCELMODE) \
373 	{ \
374 		SetMsgHandled(TRUE); \
375 		func(); \
376 		lResult = 0; \
377 		if(IsMsgHandled()) \
378 			return TRUE; \
379 	}
380 
381 // BOOL OnSetCursor(CWindow wnd, UINT nHitTest, UINT message)
382 #define MSG_WM_SETCURSOR(func) \
383 	if (uMsg == WM_SETCURSOR) \
384 	{ \
385 		SetMsgHandled(TRUE); \
386 		lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
387 		if(IsMsgHandled()) \
388 			return TRUE; \
389 	}
390 
391 // int OnMouseActivate(CWindow wndTopLevel, UINT nHitTest, UINT message)
392 #define MSG_WM_MOUSEACTIVATE(func) \
393 	if (uMsg == WM_MOUSEACTIVATE) \
394 	{ \
395 		SetMsgHandled(TRUE); \
396 		lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
397 		if(IsMsgHandled()) \
398 			return TRUE; \
399 	}
400 
401 // void OnChildActivate()
402 #define MSG_WM_CHILDACTIVATE(func) \
403 	if (uMsg == WM_CHILDACTIVATE) \
404 	{ \
405 		SetMsgHandled(TRUE); \
406 		func(); \
407 		lResult = 0; \
408 		if(IsMsgHandled()) \
409 			return TRUE; \
410 	}
411 
412 // void OnGetMinMaxInfo(LPMINMAXINFO lpMMI)
413 #define MSG_WM_GETMINMAXINFO(func) \
414 	if (uMsg == WM_GETMINMAXINFO) \
415 	{ \
416 		SetMsgHandled(TRUE); \
417 		func((LPMINMAXINFO)lParam); \
418 		lResult = 0; \
419 		if(IsMsgHandled()) \
420 			return TRUE; \
421 	}
422 
423 // void OnIconEraseBkgnd(CDCHandle dc)
424 #define MSG_WM_ICONERASEBKGND(func) \
425 	if (uMsg == WM_ICONERASEBKGND) \
426 	{ \
427 		SetMsgHandled(TRUE); \
428 		func((HDC)wParam); \
429 		lResult = 0; \
430 		if(IsMsgHandled()) \
431 			return TRUE; \
432 	}
433 
434 // void OnSpoolerStatus(UINT nStatus, UINT nJobs)
435 #define MSG_WM_SPOOLERSTATUS(func) \
436 	if (uMsg == WM_SPOOLERSTATUS) \
437 	{ \
438 		SetMsgHandled(TRUE); \
439 		func((UINT)wParam, (UINT)LOWORD(lParam)); \
440 		lResult = 0; \
441 		if(IsMsgHandled()) \
442 			return TRUE; \
443 	}
444 
445 // void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
446 #define MSG_WM_DRAWITEM(func) \
447 	if (uMsg == WM_DRAWITEM) \
448 	{ \
449 		SetMsgHandled(TRUE); \
450 		func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \
451 		lResult = TRUE; \
452 		if(IsMsgHandled()) \
453 			return TRUE; \
454 	}
455 
456 // void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
457 #define MSG_WM_MEASUREITEM(func) \
458 	if (uMsg == WM_MEASUREITEM) \
459 	{ \
460 		SetMsgHandled(TRUE); \
461 		func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \
462 		lResult = TRUE; \
463 		if(IsMsgHandled()) \
464 			return TRUE; \
465 	}
466 
467 // void OnDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct)
468 #define MSG_WM_DELETEITEM(func) \
469 	if (uMsg == WM_DELETEITEM) \
470 	{ \
471 		SetMsgHandled(TRUE); \
472 		func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \
473 		lResult = TRUE; \
474 		if(IsMsgHandled()) \
475 			return TRUE; \
476 	}
477 
478 //int OnCharToItem(UINT nChar, UINT nIndex, CListBox listBox)
479 #define MSG_WM_CHARTOITEM(func) \
480 	if (uMsg == WM_CHARTOITEM) \
481 	{ \
482 		SetMsgHandled(TRUE); \
483 		lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
484 		if(IsMsgHandled()) \
485 			return TRUE; \
486 	}
487 
488 // int OnVKeyToItem(UINT nKey, UINT nIndex, CListBox listBox)
489 #define MSG_WM_VKEYTOITEM(func) \
490 	if (uMsg == WM_VKEYTOITEM) \
491 	{ \
492 		SetMsgHandled(TRUE); \
493 		lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
494 		if(IsMsgHandled()) \
495 			return TRUE; \
496 	}
497 
498 // HCURSOR OnQueryDragIcon()
499 #define MSG_WM_QUERYDRAGICON(func) \
500 	if (uMsg == WM_QUERYDRAGICON) \
501 	{ \
502 		SetMsgHandled(TRUE); \
503 		lResult = (LRESULT)func(); \
504 		if(IsMsgHandled()) \
505 			return TRUE; \
506 	}
507 
508 // int OnCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct)
509 #define MSG_WM_COMPAREITEM(func) \
510 	if (uMsg == WM_COMPAREITEM) \
511 	{ \
512 		SetMsgHandled(TRUE); \
513 		lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \
514 		if(IsMsgHandled()) \
515 			return TRUE; \
516 	}
517 
518 // void OnCompacting(UINT nCpuTime)
519 #define MSG_WM_COMPACTING(func) \
520 	if (uMsg == WM_COMPACTING) \
521 	{ \
522 		SetMsgHandled(TRUE); \
523 		func((UINT)wParam); \
524 		lResult = 0; \
525 		if(IsMsgHandled()) \
526 			return TRUE; \
527 	}
528 
529 // BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct)
530 #define MSG_WM_NCCREATE(func) \
531 	if (uMsg == WM_NCCREATE) \
532 	{ \
533 		SetMsgHandled(TRUE); \
534 		lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \
535 		if(IsMsgHandled()) \
536 			return TRUE; \
537 	}
538 
539 // void OnNcDestroy()
540 #define MSG_WM_NCDESTROY(func) \
541 	if (uMsg == WM_NCDESTROY) \
542 	{ \
543 		SetMsgHandled(TRUE); \
544 		func(); \
545 		lResult = 0; \
546 		if(IsMsgHandled()) \
547 			return TRUE; \
548 	}
549 
550 // LRESULT OnNcCalcSize(BOOL bCalcValidRects, LPARAM lParam)
551 #define MSG_WM_NCCALCSIZE(func) \
552 	if (uMsg == WM_NCCALCSIZE) \
553 	{ \
554 		SetMsgHandled(TRUE); \
555 		lResult = func((BOOL)wParam, lParam); \
556 		if(IsMsgHandled()) \
557 			return TRUE; \
558 	}
559 
560 // UINT OnNcHitTest(CPoint point)
561 #define MSG_WM_NCHITTEST(func) \
562 	if (uMsg == WM_NCHITTEST) \
563 	{ \
564 		SetMsgHandled(TRUE); \
565 		lResult = (LRESULT)func(_WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
566 		if(IsMsgHandled()) \
567 			return TRUE; \
568 	}
569 
570 // void OnNcPaint(CRgnHandle rgn)
571 #define MSG_WM_NCPAINT(func) \
572 	if (uMsg == WM_NCPAINT) \
573 	{ \
574 		SetMsgHandled(TRUE); \
575 		func((HRGN)wParam); \
576 		lResult = 0; \
577 		if(IsMsgHandled()) \
578 			return TRUE; \
579 	}
580 
581 // BOOL OnNcActivate(BOOL bActive)
582 #define MSG_WM_NCACTIVATE(func) \
583 	if (uMsg == WM_NCACTIVATE) \
584 	{ \
585 		SetMsgHandled(TRUE); \
586 		lResult = (LRESULT)func((BOOL)wParam); \
587 		if(IsMsgHandled()) \
588 			return TRUE; \
589 	}
590 
591 // UINT OnGetDlgCode(LPMSG lpMsg)
592 #define MSG_WM_GETDLGCODE(func) \
593 	if (uMsg == WM_GETDLGCODE) \
594 	{ \
595 		SetMsgHandled(TRUE); \
596 		lResult = (LRESULT)func((LPMSG)lParam); \
597 		if(IsMsgHandled()) \
598 			return TRUE; \
599 	}
600 
601 // void OnNcMouseMove(UINT nHitTest, CPoint point)
602 #define MSG_WM_NCMOUSEMOVE(func) \
603 	if (uMsg == WM_NCMOUSEMOVE) \
604 	{ \
605 		SetMsgHandled(TRUE); \
606 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
607 		lResult = 0; \
608 		if(IsMsgHandled()) \
609 			return TRUE; \
610 	}
611 
612 // void OnNcLButtonDown(UINT nHitTest, CPoint point)
613 #define MSG_WM_NCLBUTTONDOWN(func) \
614 	if (uMsg == WM_NCLBUTTONDOWN) \
615 	{ \
616 		SetMsgHandled(TRUE); \
617 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
618 		lResult = 0; \
619 		if(IsMsgHandled()) \
620 			return TRUE; \
621 	}
622 
623 // void OnNcLButtonUp(UINT nHitTest, CPoint point)
624 #define MSG_WM_NCLBUTTONUP(func) \
625 	if (uMsg == WM_NCLBUTTONUP) \
626 	{ \
627 		SetMsgHandled(TRUE); \
628 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
629 		lResult = 0; \
630 		if(IsMsgHandled()) \
631 			return TRUE; \
632 	}
633 
634 // void OnNcLButtonDblClk(UINT nHitTest, CPoint point)
635 #define MSG_WM_NCLBUTTONDBLCLK(func) \
636 	if (uMsg == WM_NCLBUTTONDBLCLK) \
637 	{ \
638 		SetMsgHandled(TRUE); \
639 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
640 		lResult = 0; \
641 		if(IsMsgHandled()) \
642 			return TRUE; \
643 	}
644 
645 // void OnNcRButtonDown(UINT nHitTest, CPoint point)
646 #define MSG_WM_NCRBUTTONDOWN(func) \
647 	if (uMsg == WM_NCRBUTTONDOWN) \
648 	{ \
649 		SetMsgHandled(TRUE); \
650 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
651 		lResult = 0; \
652 		if(IsMsgHandled()) \
653 			return TRUE; \
654 	}
655 
656 // void OnNcRButtonUp(UINT nHitTest, CPoint point)
657 #define MSG_WM_NCRBUTTONUP(func) \
658 	if (uMsg == WM_NCRBUTTONUP) \
659 	{ \
660 		SetMsgHandled(TRUE); \
661 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
662 		lResult = 0; \
663 		if(IsMsgHandled()) \
664 			return TRUE; \
665 	}
666 
667 // void OnNcRButtonDblClk(UINT nHitTest, CPoint point)
668 #define MSG_WM_NCRBUTTONDBLCLK(func) \
669 	if (uMsg == WM_NCRBUTTONDBLCLK) \
670 	{ \
671 		SetMsgHandled(TRUE); \
672 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
673 		lResult = 0; \
674 		if(IsMsgHandled()) \
675 			return TRUE; \
676 	}
677 
678 // void OnNcMButtonDown(UINT nHitTest, CPoint point)
679 #define MSG_WM_NCMBUTTONDOWN(func) \
680 	if (uMsg == WM_NCMBUTTONDOWN) \
681 	{ \
682 		SetMsgHandled(TRUE); \
683 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
684 		lResult = 0; \
685 		if(IsMsgHandled()) \
686 			return TRUE; \
687 	}
688 
689 // void OnNcMButtonUp(UINT nHitTest, CPoint point)
690 #define MSG_WM_NCMBUTTONUP(func) \
691 	if (uMsg == WM_NCMBUTTONUP) \
692 	{ \
693 		SetMsgHandled(TRUE); \
694 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
695 		lResult = 0; \
696 		if(IsMsgHandled()) \
697 			return TRUE; \
698 	}
699 
700 // void OnNcMButtonDblClk(UINT nHitTest, CPoint point)
701 #define MSG_WM_NCMBUTTONDBLCLK(func) \
702 	if (uMsg == WM_NCMBUTTONDBLCLK) \
703 	{ \
704 		SetMsgHandled(TRUE); \
705 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
706 		lResult = 0; \
707 		if(IsMsgHandled()) \
708 			return TRUE; \
709 	}
710 
711 // void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
712 #define MSG_WM_KEYDOWN(func) \
713 	if (uMsg == WM_KEYDOWN) \
714 	{ \
715 		SetMsgHandled(TRUE); \
716 		func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
717 		lResult = 0; \
718 		if(IsMsgHandled()) \
719 			return TRUE; \
720 	}
721 
722 // void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
723 #define MSG_WM_KEYUP(func) \
724 	if (uMsg == WM_KEYUP) \
725 	{ \
726 		SetMsgHandled(TRUE); \
727 		func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
728 		lResult = 0; \
729 		if(IsMsgHandled()) \
730 			return TRUE; \
731 	}
732 
733 // void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
734 #define MSG_WM_CHAR(func) \
735 	if (uMsg == WM_CHAR) \
736 	{ \
737 		SetMsgHandled(TRUE); \
738 		func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
739 		lResult = 0; \
740 		if(IsMsgHandled()) \
741 			return TRUE; \
742 	}
743 
744 // void OnDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags)
745 #define MSG_WM_DEADCHAR(func) \
746 	if (uMsg == WM_DEADCHAR) \
747 	{ \
748 		SetMsgHandled(TRUE); \
749 		func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
750 		lResult = 0; \
751 		if(IsMsgHandled()) \
752 			return TRUE; \
753 	}
754 
755 // void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
756 #define MSG_WM_SYSKEYDOWN(func) \
757 	if (uMsg == WM_SYSKEYDOWN) \
758 	{ \
759 		SetMsgHandled(TRUE); \
760 		func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
761 		lResult = 0; \
762 		if(IsMsgHandled()) \
763 			return TRUE; \
764 	}
765 
766 // void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
767 #define MSG_WM_SYSKEYUP(func) \
768 	if (uMsg == WM_SYSKEYUP) \
769 	{ \
770 		SetMsgHandled(TRUE); \
771 		func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
772 		lResult = 0; \
773 		if(IsMsgHandled()) \
774 			return TRUE; \
775 	}
776 
777 // void OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags)
778 #define MSG_WM_SYSCHAR(func) \
779 	if (uMsg == WM_SYSCHAR) \
780 	{ \
781 		SetMsgHandled(TRUE); \
782 		func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
783 		lResult = 0; \
784 		if(IsMsgHandled()) \
785 			return TRUE; \
786 	}
787 
788 // void OnSysDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags)
789 #define MSG_WM_SYSDEADCHAR(func) \
790 	if (uMsg == WM_SYSDEADCHAR) \
791 	{ \
792 		SetMsgHandled(TRUE); \
793 		func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
794 		lResult = 0; \
795 		if(IsMsgHandled()) \
796 			return TRUE; \
797 	}
798 
799 // void OnSysCommand(UINT nID, CPoint point)
800 #define MSG_WM_SYSCOMMAND(func) \
801 	if (uMsg == WM_SYSCOMMAND) \
802 	{ \
803 		SetMsgHandled(TRUE); \
804 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
805 		lResult = 0; \
806 		if(IsMsgHandled()) \
807 			return TRUE; \
808 	}
809 
810 // void OnTCard(UINT idAction, DWORD dwActionData)
811 #define MSG_WM_TCARD(func) \
812 	if (uMsg == WM_TCARD) \
813 	{ \
814 		SetMsgHandled(TRUE); \
815 		func((UINT)wParam, (DWORD)lParam); \
816 		lResult = 0; \
817 		if(IsMsgHandled()) \
818 			return TRUE; \
819 	}
820 
821 // void OnTimer(UINT_PTR nIDEvent)
822 #define MSG_WM_TIMER(func) \
823 	if (uMsg == WM_TIMER) \
824 	{ \
825 		SetMsgHandled(TRUE); \
826 		func((UINT_PTR)wParam); \
827 		lResult = 0; \
828 		if(IsMsgHandled()) \
829 			return TRUE; \
830 	}
831 
832 // void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
833 #define MSG_WM_HSCROLL(func) \
834 	if (uMsg == WM_HSCROLL) \
835 	{ \
836 		SetMsgHandled(TRUE); \
837 		func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
838 		lResult = 0; \
839 		if(IsMsgHandled()) \
840 			return TRUE; \
841 	}
842 
843 // void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
844 #define MSG_WM_VSCROLL(func) \
845 	if (uMsg == WM_VSCROLL) \
846 	{ \
847 		SetMsgHandled(TRUE); \
848 		func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
849 		lResult = 0; \
850 		if(IsMsgHandled()) \
851 			return TRUE; \
852 	}
853 
854 // void OnInitMenu(CMenuHandle menu)
855 #define MSG_WM_INITMENU(func) \
856 	if (uMsg == WM_INITMENU) \
857 	{ \
858 		SetMsgHandled(TRUE); \
859 		func((HMENU)wParam); \
860 		lResult = 0; \
861 		if(IsMsgHandled()) \
862 			return TRUE; \
863 	}
864 
865 // void OnInitMenuPopup(CMenuHandle menuPopup, UINT nIndex, BOOL bSysMenu)
866 #define MSG_WM_INITMENUPOPUP(func) \
867 	if (uMsg == WM_INITMENUPOPUP) \
868 	{ \
869 		SetMsgHandled(TRUE); \
870 		func((HMENU)wParam, (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam)); \
871 		lResult = 0; \
872 		if(IsMsgHandled()) \
873 			return TRUE; \
874 	}
875 
876 // void OnMenuSelect(UINT nItemID, UINT nFlags, CMenuHandle menu)
877 #define MSG_WM_MENUSELECT(func) \
878 	if (uMsg == WM_MENUSELECT) \
879 	{ \
880 		SetMsgHandled(TRUE); \
881 		func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \
882 		lResult = 0; \
883 		if(IsMsgHandled()) \
884 			return TRUE; \
885 	}
886 
887 // LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenuHandle menu)
888 #define MSG_WM_MENUCHAR(func) \
889 	if (uMsg == WM_MENUCHAR) \
890 	{ \
891 		SetMsgHandled(TRUE); \
892 		lResult = func((TCHAR)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \
893 		if(IsMsgHandled()) \
894 			return TRUE; \
895 	}
896 
897 // LRESULT OnNotify(int idCtrl, LPNMHDR pnmh)
898 #define MSG_WM_NOTIFY(func) \
899 	if (uMsg == WM_NOTIFY) \
900 	{ \
901 		SetMsgHandled(TRUE); \
902 		lResult = func((int)wParam, (LPNMHDR)lParam); \
903 		if(IsMsgHandled()) \
904 			return TRUE; \
905 	}
906 
907 // void OnEnterIdle(UINT nWhy, CWindow wndWho)
908 #define MSG_WM_ENTERIDLE(func) \
909 	if (uMsg == WM_ENTERIDLE) \
910 	{ \
911 		SetMsgHandled(TRUE); \
912 		func((UINT)wParam, (HWND)lParam); \
913 		lResult = 0; \
914 		if(IsMsgHandled()) \
915 			return TRUE; \
916 	}
917 
918 // void OnMouseMove(UINT nFlags, CPoint point)
919 #define MSG_WM_MOUSEMOVE(func) \
920 	if (uMsg == WM_MOUSEMOVE) \
921 	{ \
922 		SetMsgHandled(TRUE); \
923 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
924 		lResult = 0; \
925 		if(IsMsgHandled()) \
926 			return TRUE; \
927 	}
928 
929 // BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
930 #define MSG_WM_MOUSEWHEEL(func) \
931 	if (uMsg == WM_MOUSEWHEEL) \
932 	{ \
933 		SetMsgHandled(TRUE); \
934 		lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
935 		if(IsMsgHandled()) \
936 			return TRUE; \
937 	}
938 
939 // void OnLButtonDown(UINT nFlags, CPoint point)
940 #define MSG_WM_LBUTTONDOWN(func) \
941 	if (uMsg == WM_LBUTTONDOWN) \
942 	{ \
943 		SetMsgHandled(TRUE); \
944 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
945 		lResult = 0; \
946 		if(IsMsgHandled()) \
947 			return TRUE; \
948 	}
949 
950 // void OnLButtonUp(UINT nFlags, CPoint point)
951 #define MSG_WM_LBUTTONUP(func) \
952 	if (uMsg == WM_LBUTTONUP) \
953 	{ \
954 		SetMsgHandled(TRUE); \
955 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
956 		lResult = 0; \
957 		if(IsMsgHandled()) \
958 			return TRUE; \
959 	}
960 
961 // void OnLButtonDblClk(UINT nFlags, CPoint point)
962 #define MSG_WM_LBUTTONDBLCLK(func) \
963 	if (uMsg == WM_LBUTTONDBLCLK) \
964 	{ \
965 		SetMsgHandled(TRUE); \
966 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
967 		lResult = 0; \
968 		if(IsMsgHandled()) \
969 			return TRUE; \
970 	}
971 
972 // void OnRButtonDown(UINT nFlags, CPoint point)
973 #define MSG_WM_RBUTTONDOWN(func) \
974 	if (uMsg == WM_RBUTTONDOWN) \
975 	{ \
976 		SetMsgHandled(TRUE); \
977 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
978 		lResult = 0; \
979 		if(IsMsgHandled()) \
980 			return TRUE; \
981 	}
982 
983 // void OnRButtonUp(UINT nFlags, CPoint point)
984 #define MSG_WM_RBUTTONUP(func) \
985 	if (uMsg == WM_RBUTTONUP) \
986 	{ \
987 		SetMsgHandled(TRUE); \
988 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
989 		lResult = 0; \
990 		if(IsMsgHandled()) \
991 			return TRUE; \
992 	}
993 
994 // void OnRButtonDblClk(UINT nFlags, CPoint point)
995 #define MSG_WM_RBUTTONDBLCLK(func) \
996 	if (uMsg == WM_RBUTTONDBLCLK) \
997 	{ \
998 		SetMsgHandled(TRUE); \
999 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1000 		lResult = 0; \
1001 		if(IsMsgHandled()) \
1002 			return TRUE; \
1003 	}
1004 
1005 // void OnMButtonDown(UINT nFlags, CPoint point)
1006 #define MSG_WM_MBUTTONDOWN(func) \
1007 	if (uMsg == WM_MBUTTONDOWN) \
1008 	{ \
1009 		SetMsgHandled(TRUE); \
1010 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1011 		lResult = 0; \
1012 		if(IsMsgHandled()) \
1013 			return TRUE; \
1014 	}
1015 
1016 // void OnMButtonUp(UINT nFlags, CPoint point)
1017 #define MSG_WM_MBUTTONUP(func) \
1018 	if (uMsg == WM_MBUTTONUP) \
1019 	{ \
1020 		SetMsgHandled(TRUE); \
1021 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1022 		lResult = 0; \
1023 		if(IsMsgHandled()) \
1024 			return TRUE; \
1025 	}
1026 
1027 // void OnMButtonDblClk(UINT nFlags, CPoint point)
1028 #define MSG_WM_MBUTTONDBLCLK(func) \
1029 	if (uMsg == WM_MBUTTONDBLCLK) \
1030 	{ \
1031 		SetMsgHandled(TRUE); \
1032 		func((UINT)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1033 		lResult = 0; \
1034 		if(IsMsgHandled()) \
1035 			return TRUE; \
1036 	}
1037 
1038 // void OnParentNotify(UINT message, UINT nChildID, LPARAM lParam)
1039 #define MSG_WM_PARENTNOTIFY(func) \
1040 	if (uMsg == WM_PARENTNOTIFY) \
1041 	{ \
1042 		SetMsgHandled(TRUE); \
1043 		func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \
1044 		lResult = 0; \
1045 		if(IsMsgHandled()) \
1046 			return TRUE; \
1047 	}
1048 
1049 // void OnMDIActivate(CWindow wndActivate, CWindow wndDeactivate)
1050 #define MSG_WM_MDIACTIVATE(func) \
1051 	if (uMsg == WM_MDIACTIVATE) \
1052 	{ \
1053 		SetMsgHandled(TRUE); \
1054 		func((HWND)wParam, (HWND)lParam); \
1055 		lResult = 0; \
1056 		if(IsMsgHandled()) \
1057 			return TRUE; \
1058 	}
1059 
1060 // void OnRenderFormat(UINT nFormat)
1061 #define MSG_WM_RENDERFORMAT(func) \
1062 	if (uMsg == WM_RENDERFORMAT) \
1063 	{ \
1064 		SetMsgHandled(TRUE); \
1065 		func((UINT)wParam); \
1066 		lResult = 0; \
1067 		if(IsMsgHandled()) \
1068 			return TRUE; \
1069 	}
1070 
1071 // void OnRenderAllFormats()
1072 #define MSG_WM_RENDERALLFORMATS(func) \
1073 	if (uMsg == WM_RENDERALLFORMATS) \
1074 	{ \
1075 		SetMsgHandled(TRUE); \
1076 		func(); \
1077 		lResult = 0; \
1078 		if(IsMsgHandled()) \
1079 			return TRUE; \
1080 	}
1081 
1082 // void OnDestroyClipboard()
1083 #define MSG_WM_DESTROYCLIPBOARD(func) \
1084 	if (uMsg == WM_DESTROYCLIPBOARD) \
1085 	{ \
1086 		SetMsgHandled(TRUE); \
1087 		func(); \
1088 		lResult = 0; \
1089 		if(IsMsgHandled()) \
1090 			return TRUE; \
1091 	}
1092 
1093 // void OnDrawClipboard()
1094 #define MSG_WM_DRAWCLIPBOARD(func) \
1095 	if (uMsg == WM_DRAWCLIPBOARD) \
1096 	{ \
1097 		SetMsgHandled(TRUE); \
1098 		func(); \
1099 		lResult = 0; \
1100 		if(IsMsgHandled()) \
1101 			return TRUE; \
1102 	}
1103 
1104 // void OnPaintClipboard(CWindow wndViewer, const LPPAINTSTRUCT lpPaintStruct)
1105 #define MSG_WM_PAINTCLIPBOARD(func) \
1106 	if (uMsg == WM_PAINTCLIPBOARD) \
1107 	{ \
1108 		SetMsgHandled(TRUE); \
1109 		func((HWND)wParam, (const LPPAINTSTRUCT)::GlobalLock((HGLOBAL)lParam)); \
1110 		::GlobalUnlock((HGLOBAL)lParam); \
1111 		lResult = 0; \
1112 		if(IsMsgHandled()) \
1113 			return TRUE; \
1114 	}
1115 
1116 // void OnVScrollClipboard(CWindow wndViewer, UINT nSBCode, UINT nPos)
1117 #define MSG_WM_VSCROLLCLIPBOARD(func) \
1118 	if (uMsg == WM_VSCROLLCLIPBOARD) \
1119 	{ \
1120 		SetMsgHandled(TRUE); \
1121 		func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
1122 		lResult = 0; \
1123 		if(IsMsgHandled()) \
1124 			return TRUE; \
1125 	}
1126 
1127 // void OnContextMenu(CWindow wnd, CPoint point)
1128 #define MSG_WM_CONTEXTMENU(func) \
1129 	if (uMsg == WM_CONTEXTMENU) \
1130 	{ \
1131 		SetMsgHandled(TRUE); \
1132 		func((HWND)wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1133 		lResult = 0; \
1134 		if(IsMsgHandled()) \
1135 			return TRUE; \
1136 	}
1137 
1138 // void OnSizeClipboard(CWindow wndViewer, const LPRECT lpRect)
1139 #define MSG_WM_SIZECLIPBOARD(func) \
1140 	if (uMsg == WM_SIZECLIPBOARD) \
1141 	{ \
1142 		SetMsgHandled(TRUE); \
1143 		func((HWND)wParam, (const LPRECT)::GlobalLock((HGLOBAL)lParam)); \
1144 		::GlobalUnlock((HGLOBAL)lParam); \
1145 		lResult = 0; \
1146 		if(IsMsgHandled()) \
1147 			return TRUE; \
1148 	}
1149 
1150 // void OnAskCbFormatName(UINT nMaxCount, LPTSTR lpszString)
1151 #define MSG_WM_ASKCBFORMATNAME(func) \
1152 	if (uMsg == WM_ASKCBFORMATNAME) \
1153 	{ \
1154 		SetMsgHandled(TRUE); \
1155 		func((UINT)wParam, (LPTSTR)lParam); \
1156 		lResult = 0; \
1157 		if(IsMsgHandled()) \
1158 			return TRUE; \
1159 	}
1160 
1161 // void OnChangeCbChain(CWindow wndRemove, CWindow wndAfter)
1162 #define MSG_WM_CHANGECBCHAIN(func) \
1163 	if (uMsg == WM_CHANGECBCHAIN) \
1164 	{ \
1165 		SetMsgHandled(TRUE); \
1166 		func((HWND)wParam, (HWND)lParam); \
1167 		lResult = 0; \
1168 		if(IsMsgHandled()) \
1169 			return TRUE; \
1170 	}
1171 
1172 // void OnHScrollClipboard(CWindow wndViewer, UINT nSBCode, UINT nPos)
1173 #define MSG_WM_HSCROLLCLIPBOARD(func) \
1174 	if (uMsg == WM_HSCROLLCLIPBOARD) \
1175 	{ \
1176 		SetMsgHandled(TRUE); \
1177 		func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
1178 		lResult = 0; \
1179 		if(IsMsgHandled()) \
1180 			return TRUE; \
1181 	}
1182 
1183 // BOOL OnQueryNewPalette()
1184 #define MSG_WM_QUERYNEWPALETTE(func) \
1185 	if (uMsg == WM_QUERYNEWPALETTE) \
1186 	{ \
1187 		SetMsgHandled(TRUE); \
1188 		lResult = (LRESULT)func(); \
1189 		if(IsMsgHandled()) \
1190 			return TRUE; \
1191 	}
1192 
1193 // void OnPaletteChanged(CWindow wndFocus)
1194 #define MSG_WM_PALETTECHANGED(func) \
1195 	if (uMsg == WM_PALETTECHANGED) \
1196 	{ \
1197 		SetMsgHandled(TRUE); \
1198 		func((HWND)wParam); \
1199 		lResult = 0; \
1200 		if(IsMsgHandled()) \
1201 			return TRUE; \
1202 	}
1203 
1204 // void OnPaletteIsChanging(CWindow wndPalChg)
1205 #define MSG_WM_PALETTEISCHANGING(func) \
1206 	if (uMsg == WM_PALETTEISCHANGING) \
1207 	{ \
1208 		SetMsgHandled(TRUE); \
1209 		func((HWND)wParam); \
1210 		lResult = 0; \
1211 		if(IsMsgHandled()) \
1212 			return TRUE; \
1213 	}
1214 
1215 // void OnDropFiles(HDROP hDropInfo)
1216 #define MSG_WM_DROPFILES(func) \
1217 	if (uMsg == WM_DROPFILES) \
1218 	{ \
1219 		SetMsgHandled(TRUE); \
1220 		func((HDROP)wParam); \
1221 		lResult = 0; \
1222 		if(IsMsgHandled()) \
1223 			return TRUE; \
1224 	}
1225 
1226 // void OnWindowPosChanging(LPWINDOWPOS lpWndPos)
1227 #define MSG_WM_WINDOWPOSCHANGING(func) \
1228 	if (uMsg == WM_WINDOWPOSCHANGING) \
1229 	{ \
1230 		SetMsgHandled(TRUE); \
1231 		func((LPWINDOWPOS)lParam); \
1232 		lResult = 0; \
1233 		if(IsMsgHandled()) \
1234 			return TRUE; \
1235 	}
1236 
1237 // void OnWindowPosChanged(LPWINDOWPOS lpWndPos)
1238 #define MSG_WM_WINDOWPOSCHANGED(func) \
1239 	if (uMsg == WM_WINDOWPOSCHANGED) \
1240 	{ \
1241 		SetMsgHandled(TRUE); \
1242 		func((LPWINDOWPOS)lParam); \
1243 		lResult = 0; \
1244 		if(IsMsgHandled()) \
1245 			return TRUE; \
1246 	}
1247 
1248 // void OnExitMenuLoop(BOOL fIsTrackPopupMenu)
1249 #define MSG_WM_EXITMENULOOP(func) \
1250 	if (uMsg == WM_EXITMENULOOP) \
1251 	{ \
1252 		SetMsgHandled(TRUE); \
1253 		func((BOOL)wParam); \
1254 		lResult = 0; \
1255 		if(IsMsgHandled()) \
1256 			return TRUE; \
1257 	}
1258 
1259 // void OnEnterMenuLoop(BOOL fIsTrackPopupMenu)
1260 #define MSG_WM_ENTERMENULOOP(func) \
1261 	if (uMsg == WM_ENTERMENULOOP) \
1262 	{ \
1263 		SetMsgHandled(TRUE); \
1264 		func((BOOL)wParam); \
1265 		lResult = 0; \
1266 		if(IsMsgHandled()) \
1267 			return TRUE; \
1268 	}
1269 
1270 // void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct)
1271 #define MSG_WM_STYLECHANGED(func) \
1272 	if (uMsg == WM_STYLECHANGED) \
1273 	{ \
1274 		SetMsgHandled(TRUE); \
1275 		func((UINT)wParam, (LPSTYLESTRUCT)lParam); \
1276 		lResult = 0; \
1277 		if(IsMsgHandled()) \
1278 			return TRUE; \
1279 	}
1280 
1281 // void OnStyleChanging(int nStyleType, LPSTYLESTRUCT lpStyleStruct)
1282 #define MSG_WM_STYLECHANGING(func) \
1283 	if (uMsg == WM_STYLECHANGING) \
1284 	{ \
1285 		SetMsgHandled(TRUE); \
1286 		func((UINT)wParam, (LPSTYLESTRUCT)lParam); \
1287 		lResult = 0; \
1288 		if(IsMsgHandled()) \
1289 			return TRUE; \
1290 	}
1291 
1292 // void OnSizing(UINT fwSide, LPRECT pRect)
1293 #define MSG_WM_SIZING(func) \
1294 	if (uMsg == WM_SIZING) \
1295 	{ \
1296 		SetMsgHandled(TRUE); \
1297 		func((UINT)wParam, (LPRECT)lParam); \
1298 		lResult = TRUE; \
1299 		if(IsMsgHandled()) \
1300 			return TRUE; \
1301 	}
1302 
1303 // void OnMoving(UINT fwSide, LPRECT pRect)
1304 #define MSG_WM_MOVING(func) \
1305 	if (uMsg == WM_MOVING) \
1306 	{ \
1307 		SetMsgHandled(TRUE); \
1308 		func((UINT)wParam, (LPRECT)lParam); \
1309 		lResult = TRUE; \
1310 		if(IsMsgHandled()) \
1311 			return TRUE; \
1312 	}
1313 
1314 // void OnCaptureChanged(CWindow wnd)
1315 #define MSG_WM_CAPTURECHANGED(func) \
1316 	if (uMsg == WM_CAPTURECHANGED) \
1317 	{ \
1318 		SetMsgHandled(TRUE); \
1319 		func((HWND)lParam); \
1320 		lResult = 0; \
1321 		if(IsMsgHandled()) \
1322 			return TRUE; \
1323 	}
1324 
1325 // BOOL OnDeviceChange(UINT nEventType, DWORD_PTR dwData)
1326 #define MSG_WM_DEVICECHANGE(func) \
1327 	if (uMsg == WM_DEVICECHANGE) \
1328 	{ \
1329 		SetMsgHandled(TRUE); \
1330 		lResult = (LRESULT)func((UINT)wParam, (DWORD_PTR)lParam); \
1331 		if(IsMsgHandled()) \
1332 			return TRUE; \
1333 	}
1334 
1335 // void OnCommand(UINT uNotifyCode, int nID, CWindow wndCtl)
1336 #define MSG_WM_COMMAND(func) \
1337 	if (uMsg == WM_COMMAND) \
1338 	{ \
1339 		SetMsgHandled(TRUE); \
1340 		func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
1341 		lResult = 0; \
1342 		if(IsMsgHandled()) \
1343 			return TRUE; \
1344 	}
1345 
1346 // void OnDisplayChange(UINT uBitsPerPixel, CSize sizeScreen)
1347 #define MSG_WM_DISPLAYCHANGE(func) \
1348 	if (uMsg == WM_DISPLAYCHANGE) \
1349 	{ \
1350 		SetMsgHandled(TRUE); \
1351 		func((UINT)wParam, _WTYPES_NS::CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1352 		lResult = 0; \
1353 		if(IsMsgHandled()) \
1354 			return TRUE; \
1355 	}
1356 
1357 // void OnEnterSizeMove()
1358 #define MSG_WM_ENTERSIZEMOVE(func) \
1359 	if (uMsg == WM_ENTERSIZEMOVE) \
1360 	{ \
1361 		SetMsgHandled(TRUE); \
1362 		func(); \
1363 		lResult = 0; \
1364 		if(IsMsgHandled()) \
1365 			return TRUE; \
1366 	}
1367 
1368 // void OnExitSizeMove()
1369 #define MSG_WM_EXITSIZEMOVE(func) \
1370 	if (uMsg == WM_EXITSIZEMOVE) \
1371 	{ \
1372 		SetMsgHandled(TRUE); \
1373 		func(); \
1374 		lResult = 0; \
1375 		if(IsMsgHandled()) \
1376 			return TRUE; \
1377 	}
1378 
1379 // HFONT OnGetFont()
1380 #define MSG_WM_GETFONT(func) \
1381 	if (uMsg == WM_GETFONT) \
1382 	{ \
1383 		SetMsgHandled(TRUE); \
1384 		lResult = (LRESULT)func(); \
1385 		if(IsMsgHandled()) \
1386 			return TRUE; \
1387 	}
1388 
1389 // LRESULT OnGetHotKey()
1390 #define MSG_WM_GETHOTKEY(func) \
1391 	if (uMsg == WM_GETHOTKEY) \
1392 	{ \
1393 		SetMsgHandled(TRUE); \
1394 		lResult = func(); \
1395 		if(IsMsgHandled()) \
1396 			return TRUE; \
1397 	}
1398 
1399 // HICON OnGetIcon()
1400 #define MSG_WM_GETICON(func) \
1401 	if (uMsg == WM_GETICON) \
1402 	{ \
1403 		SetMsgHandled(TRUE); \
1404 		lResult = (LRESULT)func((UINT)wParam); \
1405 		if(IsMsgHandled()) \
1406 			return TRUE; \
1407 	}
1408 
1409 // int OnGetText(int cchTextMax, LPTSTR lpszText)
1410 #define MSG_WM_GETTEXT(func) \
1411 	if (uMsg == WM_GETTEXT) \
1412 	{ \
1413 		SetMsgHandled(TRUE); \
1414 		lResult = (LRESULT)func((int)wParam, (LPTSTR)lParam); \
1415 		if(IsMsgHandled()) \
1416 			return TRUE; \
1417 	}
1418 
1419 // int OnGetTextLength()
1420 #define MSG_WM_GETTEXTLENGTH(func) \
1421 	if (uMsg == WM_GETTEXTLENGTH) \
1422 	{ \
1423 		SetMsgHandled(TRUE); \
1424 		lResult = (LRESULT)func(); \
1425 		if(IsMsgHandled()) \
1426 			return TRUE; \
1427 	}
1428 
1429 // void OnHelp(LPHELPINFO lpHelpInfo)
1430 #define MSG_WM_HELP(func) \
1431 	if (uMsg == WM_HELP) \
1432 	{ \
1433 		SetMsgHandled(TRUE); \
1434 		func((LPHELPINFO)lParam); \
1435 		lResult = TRUE; \
1436 		if(IsMsgHandled()) \
1437 			return TRUE; \
1438 	}
1439 
1440 // void OnHotKey(int nHotKeyID, UINT uModifiers, UINT uVirtKey)
1441 #define MSG_WM_HOTKEY(func) \
1442 	if (uMsg == WM_HOTKEY) \
1443 	{ \
1444 		SetMsgHandled(TRUE); \
1445 		func((int)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
1446 		lResult = 0; \
1447 		if(IsMsgHandled()) \
1448 			return TRUE; \
1449 	}
1450 
1451 // void OnInputLangChange(DWORD dwCharSet, HKL hKbdLayout)
1452 #define MSG_WM_INPUTLANGCHANGE(func) \
1453 	if (uMsg == WM_INPUTLANGCHANGE) \
1454 	{ \
1455 		SetMsgHandled(TRUE); \
1456 		func((DWORD)wParam, (HKL)lParam); \
1457 		lResult = TRUE; \
1458 		if(IsMsgHandled()) \
1459 			return TRUE; \
1460 	}
1461 
1462 // void OnInputLangChangeRequest(BOOL bSysCharSet, HKL hKbdLayout)
1463 #define MSG_WM_INPUTLANGCHANGEREQUEST(func) \
1464 	if (uMsg == WM_INPUTLANGCHANGEREQUEST) \
1465 	{ \
1466 		SetMsgHandled(TRUE); \
1467 		func((BOOL)wParam, (HKL)lParam); \
1468 		lResult = 0; \
1469 		if(IsMsgHandled()) \
1470 			return TRUE; \
1471 	}
1472 
1473 // void OnNextDlgCtl(BOOL bHandle, WPARAM wCtlFocus)
1474 #define MSG_WM_NEXTDLGCTL(func) \
1475 	if (uMsg == WM_NEXTDLGCTL) \
1476 	{ \
1477 		SetMsgHandled(TRUE); \
1478 		func((BOOL)LOWORD(lParam), wParam); \
1479 		lResult = 0; \
1480 		if(IsMsgHandled()) \
1481 			return TRUE; \
1482 	}
1483 
1484 // void OnNextMenu(int nVirtKey, LPMDINEXTMENU lpMdiNextMenu)
1485 #define MSG_WM_NEXTMENU(func) \
1486 	if (uMsg == WM_NEXTMENU) \
1487 	{ \
1488 		SetMsgHandled(TRUE); \
1489 		func((int)wParam, (LPMDINEXTMENU)lParam); \
1490 		lResult = 0; \
1491 		if(IsMsgHandled()) \
1492 			return TRUE; \
1493 	}
1494 
1495 // int OnNotifyFormat(CWindow wndFrom, int nCommand)
1496 #define MSG_WM_NOTIFYFORMAT(func) \
1497 	if (uMsg == WM_NOTIFYFORMAT) \
1498 	{ \
1499 		SetMsgHandled(TRUE); \
1500 		lResult = (LRESULT)func((HWND)wParam, (int)lParam); \
1501 		if(IsMsgHandled()) \
1502 			return TRUE; \
1503 	}
1504 
1505 // BOOL OnPowerBroadcast(DWORD dwPowerEvent, DWORD_PTR dwData)
1506 #define MSG_WM_POWERBROADCAST(func) \
1507 	if (uMsg == WM_POWERBROADCAST) \
1508 	{ \
1509 		SetMsgHandled(TRUE); \
1510 		lResult = (LRESULT)func((DWORD)wParam, (DWORD_PTR)lParam); \
1511 		if(IsMsgHandled()) \
1512 			return TRUE; \
1513 	}
1514 
1515 // void OnPrint(CDCHandle dc, UINT uFlags)
1516 #define MSG_WM_PRINT(func) \
1517 	if (uMsg == WM_PRINT) \
1518 	{ \
1519 		SetMsgHandled(TRUE); \
1520 		func((HDC)wParam, (UINT)lParam); \
1521 		lResult = 0; \
1522 		if(IsMsgHandled()) \
1523 			return TRUE; \
1524 	}
1525 
1526 // void OnPrintClient(CDCHandle dc, UINT uFlags)
1527 #define MSG_WM_PRINTCLIENT(func) \
1528 	if (uMsg == WM_PRINTCLIENT) \
1529 	{ \
1530 		SetMsgHandled(TRUE); \
1531 		func((HDC)wParam, (UINT)lParam); \
1532 		lResult = 0; \
1533 		if(IsMsgHandled()) \
1534 			return TRUE; \
1535 	}
1536 
1537 // void OnRasDialEvent(RASCONNSTATE rasconnstate, DWORD dwError)
1538 #define MSG_WM_RASDIALEVENT(func) \
1539 	if (uMsg == WM_RASDIALEVENT) \
1540 	{ \
1541 		SetMsgHandled(TRUE); \
1542 		func((RASCONNSTATE)wParam, (DWORD)lParam); \
1543 		lResult = TRUE; \
1544 		if(IsMsgHandled()) \
1545 			return TRUE; \
1546 	}
1547 
1548 // void OnSetFont(CFontHandle font, BOOL bRedraw)
1549 #define MSG_WM_SETFONT(func) \
1550 	if (uMsg == WM_SETFONT) \
1551 	{ \
1552 		SetMsgHandled(TRUE); \
1553 		func((HFONT)wParam, (BOOL)LOWORD(lParam)); \
1554 		lResult = 0; \
1555 		if(IsMsgHandled()) \
1556 			return TRUE; \
1557 	}
1558 
1559 // int OnSetHotKey(int nVirtKey, UINT uFlags)
1560 #define MSG_WM_SETHOTKEY(func) \
1561 	if (uMsg == WM_SETHOTKEY) \
1562 	{ \
1563 		SetMsgHandled(TRUE); \
1564 		lResult = (LRESULT)func((int)LOBYTE(LOWORD(wParam)), (UINT)HIBYTE(LOWORD(wParam))); \
1565 		if(IsMsgHandled()) \
1566 			return TRUE; \
1567 	}
1568 
1569 // HICON OnSetIcon(UINT uType, HICON hIcon)
1570 #define MSG_WM_SETICON(func) \
1571 	if (uMsg == WM_SETICON) \
1572 	{ \
1573 		SetMsgHandled(TRUE); \
1574 		lResult = (LRESULT)func((UINT)wParam, (HICON)lParam); \
1575 		if(IsMsgHandled()) \
1576 			return TRUE; \
1577 	}
1578 
1579 // void OnSetRedraw(BOOL bRedraw)
1580 #define MSG_WM_SETREDRAW(func) \
1581 	if (uMsg == WM_SETREDRAW) \
1582 	{ \
1583 		SetMsgHandled(TRUE); \
1584 		func((BOOL)wParam); \
1585 		lResult = 0; \
1586 		if(IsMsgHandled()) \
1587 			return TRUE; \
1588 	}
1589 
1590 // int OnSetText(LPCTSTR lpstrText)
1591 #define MSG_WM_SETTEXT(func) \
1592 	if (uMsg == WM_SETTEXT) \
1593 	{ \
1594 		SetMsgHandled(TRUE); \
1595 		lResult = (LRESULT)func((LPCTSTR)lParam); \
1596 		if(IsMsgHandled()) \
1597 			return TRUE; \
1598 	}
1599 
1600 // void OnUserChanged()
1601 #define MSG_WM_USERCHANGED(func) \
1602 	if (uMsg == WM_USERCHANGED) \
1603 	{ \
1604 		SetMsgHandled(TRUE); \
1605 		func(); \
1606 		lResult = 0; \
1607 		if(IsMsgHandled()) \
1608 			return TRUE; \
1609 	}
1610 
1611 ///////////////////////////////////////////////////////////////////////////////
1612 // New NT4 & NT5 messages
1613 
1614 #if (_WIN32_WINNT >= 0x0400)
1615 
1616 // void OnMouseHover(WPARAM wParam, CPoint ptPos)
1617 #define MSG_WM_MOUSEHOVER(func) \
1618 	if (uMsg == WM_MOUSEHOVER) \
1619 	{ \
1620 		SetMsgHandled(TRUE); \
1621 		func(wParam, _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1622 		lResult = 0; \
1623 		if(IsMsgHandled()) \
1624 			return TRUE; \
1625 	}
1626 
1627 // void OnMouseLeave()
1628 #define MSG_WM_MOUSELEAVE(func) \
1629 	if (uMsg == WM_MOUSELEAVE) \
1630 	{ \
1631 		SetMsgHandled(TRUE); \
1632 		func(); \
1633 		lResult = 0; \
1634 		if(IsMsgHandled()) \
1635 			return TRUE; \
1636 	}
1637 
1638 #endif // _WIN32_WINNT >= 0x0400
1639 
1640 #if (WINVER >= 0x0500)
1641 
1642 // void OnMenuRButtonUp(WPARAM wParam, CMenuHandle menu)
1643 #define MSG_WM_MENURBUTTONUP(func) \
1644 	if (uMsg == WM_MENURBUTTONUP) \
1645 	{ \
1646 		SetMsgHandled(TRUE); \
1647 		func(wParam, (HMENU)lParam); \
1648 		lResult = 0; \
1649 		if(IsMsgHandled()) \
1650 			return TRUE; \
1651 	}
1652 
1653 // LRESULT OnMenuDrag(WPARAM wParam, CMenuHandle menu)
1654 #define MSG_WM_MENUDRAG(func) \
1655 	if (uMsg == WM_MENUDRAG) \
1656 	{ \
1657 		SetMsgHandled(TRUE); \
1658 		lResult = func(wParam, (HMENU)lParam); \
1659 		if(IsMsgHandled()) \
1660 			return TRUE; \
1661 	}
1662 
1663 // LRESULT OnMenuGetObject(PMENUGETOBJECTINFO info)
1664 #define MSG_WM_MENUGETOBJECT(func) \
1665 	if (uMsg == WM_MENUGETOBJECT) \
1666 	{ \
1667 		SetMsgHandled(TRUE); \
1668 		lResult = func((PMENUGETOBJECTINFO)lParam); \
1669 		if(IsMsgHandled()) \
1670 			return TRUE; \
1671 	}
1672 
1673 // void OnUnInitMenuPopup(UINT nID, CMenuHandle menu)
1674 #define MSG_WM_UNINITMENUPOPUP(func) \
1675 	if (uMsg == WM_UNINITMENUPOPUP) \
1676 	{ \
1677 		SetMsgHandled(TRUE); \
1678 		func((UINT)HIWORD(lParam), (HMENU)wParam); \
1679 		lResult = 0; \
1680 		if(IsMsgHandled()) \
1681 			return TRUE; \
1682 	}
1683 
1684 // void OnMenuCommand(WPARAM nIndex, CMenuHandle menu)
1685 #define MSG_WM_MENUCOMMAND(func) \
1686 	if (uMsg == WM_MENUCOMMAND) \
1687 	{ \
1688 		SetMsgHandled(TRUE); \
1689 		func(wParam, (HMENU)lParam); \
1690 		lResult = 0; \
1691 		if(IsMsgHandled()) \
1692 			return TRUE; \
1693 	}
1694 
1695 #endif // WINVER >= 0x0500
1696 
1697 #if (_WIN32_WINNT >= 0x0500)
1698 
1699 // BOOL OnAppCommand(CWindow wndFocus, short cmd, WORD uDevice, int dwKeys)
1700 #define MSG_WM_APPCOMMAND(func) \
1701 	if (uMsg == WM_APPCOMMAND) \
1702 	{ \
1703 		SetMsgHandled(TRUE); \
1704 		lResult = (LRESULT)func((HWND)wParam, GET_APPCOMMAND_LPARAM(lParam), GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam)); \
1705 		if(IsMsgHandled()) \
1706 			return TRUE; \
1707 	}
1708 
1709 // void OnNCXButtonDown(int fwButton, short nHittest, CPoint ptPos)
1710 #define MSG_WM_NCXBUTTONDOWN(func) \
1711 	if (uMsg == WM_NCXBUTTONDOWN) \
1712 	{ \
1713 		SetMsgHandled(TRUE); \
1714 		func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1715 		lResult = 0; \
1716 		if(IsMsgHandled()) \
1717 			return TRUE; \
1718 	}
1719 
1720 // void OnNCXButtonUp(int fwButton, short nHittest, CPoint ptPos)
1721 #define MSG_WM_NCXBUTTONUP(func) \
1722 	if (uMsg == WM_NCXBUTTONUP) \
1723 	{ \
1724 		SetMsgHandled(TRUE); \
1725 		func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1726 		lResult = 0; \
1727 		if(IsMsgHandled()) \
1728 			return TRUE; \
1729 	}
1730 
1731 // void OnNCXButtonDblClk(int fwButton, short nHittest, CPoint ptPos)
1732 #define MSG_WM_NCXBUTTONDBLCLK(func) \
1733 	if (uMsg == WM_NCXBUTTONDBLCLK) \
1734 	{ \
1735 		SetMsgHandled(TRUE); \
1736 		func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1737 		lResult = 0; \
1738 		if(IsMsgHandled()) \
1739 			return TRUE; \
1740 	}
1741 
1742 // void OnXButtonDown(int fwButton, int dwKeys, CPoint ptPos)
1743 #define MSG_WM_XBUTTONDOWN(func) \
1744 	if (uMsg == WM_XBUTTONDOWN) \
1745 	{ \
1746 		SetMsgHandled(TRUE); \
1747 		func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1748 		lResult = 0; \
1749 		if(IsMsgHandled()) \
1750 			return TRUE; \
1751 	}
1752 
1753 // void OnXButtonUp(int fwButton, int dwKeys, CPoint ptPos)
1754 #define MSG_WM_XBUTTONUP(func) \
1755 	if (uMsg == WM_XBUTTONUP) \
1756 	{ \
1757 		SetMsgHandled(TRUE); \
1758 		func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1759 		lResult = 0; \
1760 		if(IsMsgHandled()) \
1761 			return TRUE; \
1762 	}
1763 
1764 // void OnXButtonDblClk(int fwButton, int dwKeys, CPoint ptPos)
1765 #define MSG_WM_XBUTTONDBLCLK(func) \
1766 	if (uMsg == WM_XBUTTONDBLCLK) \
1767 	{ \
1768 		SetMsgHandled(TRUE); \
1769 		func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1770 		lResult = 0; \
1771 		if(IsMsgHandled()) \
1772 			return TRUE; \
1773 	}
1774 
1775 // void OnChangeUIState(WORD nAction, WORD nState)
1776 #define MSG_WM_CHANGEUISTATE(func) \
1777 	if (uMsg == WM_CHANGEUISTATE) \
1778 	{ \
1779 		SetMsgHandled(TRUE); \
1780 		func(LOWORD(wParam), HIWORD(wParam)); \
1781 		lResult = 0; \
1782 		if(IsMsgHandled()) \
1783 			return TRUE; \
1784 	}
1785 
1786 // void OnUpdateUIState(WORD nAction, WORD nState)
1787 #define MSG_WM_UPDATEUISTATE(func) \
1788 	if (uMsg == WM_UPDATEUISTATE) \
1789 	{ \
1790 		SetMsgHandled(TRUE); \
1791 		func(LOWORD(wParam), HIWORD(wParam)); \
1792 		lResult = 0; \
1793 		if(IsMsgHandled()) \
1794 			return TRUE; \
1795 	}
1796 
1797 // LRESULT OnQueryUIState()
1798 #define MSG_WM_QUERYUISTATE(func) \
1799 	if (uMsg == WM_QUERYUISTATE) \
1800 	{ \
1801 		SetMsgHandled(TRUE); \
1802 		lResult = func(); \
1803 		if(IsMsgHandled()) \
1804 			return TRUE; \
1805 	}
1806 
1807 #endif // (_WIN32_WINNT >= 0x0500)
1808 
1809 #if(_WIN32_WINNT >= 0x0501)
1810 
1811 // void OnInput(WPARAM RawInputCode, HRAWINPUT hRawInput)
1812 #define MSG_WM_INPUT(func) \
1813 	if (uMsg == WM_INPUT) \
1814 	{ \
1815 		SetMsgHandled(TRUE); \
1816 		func(GET_RAWINPUT_CODE_WPARAM(wParam), (HRAWINPUT)lParam); \
1817 		lResult = 0; \
1818 		if(IsMsgHandled()) \
1819 			return TRUE; \
1820 	}
1821 
1822 // void OnUniChar(TCHAR nChar, UINT nRepCnt, UINT nFlags)
1823 #define MSG_WM_UNICHAR(func) \
1824 	if (uMsg == WM_UNICHAR) \
1825 	{ \
1826 		SetMsgHandled(TRUE); \
1827 		func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
1828 		if(IsMsgHandled()) \
1829 		{ \
1830 			lResult = (wParam == UNICODE_NOCHAR) ? TRUE : FALSE; \
1831 			return TRUE; \
1832 		} \
1833 	}
1834 
1835 // void OnWTSSessionChange(WPARAM nStatusCode, PWTSSESSION_NOTIFICATION nSessionID)
1836 #define MSG_WM_WTSSESSION_CHANGE(func) \
1837 	if (uMsg == WM_WTSSESSION_CHANGE) \
1838 	{ \
1839 		SetMsgHandled(TRUE); \
1840 		func(wParam, (PWTSSESSION_NOTIFICATION)lParam); \
1841 		lResult = 0; \
1842 		if(IsMsgHandled()) \
1843 			return TRUE; \
1844 	}
1845 
1846 // void OnThemeChanged()
1847 #define MSG_WM_THEMECHANGED(func) \
1848 	if (uMsg == WM_THEMECHANGED) \
1849 	{ \
1850 		SetMsgHandled(TRUE); \
1851 		func(); \
1852 		lResult = 0; \
1853 		if(IsMsgHandled()) \
1854 			return TRUE; \
1855 	}
1856 
1857 #endif // _WIN32_WINNT >= 0x0501
1858 
1859 #if (_WIN32_WINNT >= 0x0600)
1860 
1861 // BOOL OnMouseHWheel(UINT nFlags, short zDelta, CPoint pt)
1862 #define MSG_WM_MOUSEHWHEEL(func) \
1863 	if (uMsg == WM_MOUSEHWHEEL) \
1864 	{ \
1865 		SetMsgHandled(TRUE); \
1866 		lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), _WTYPES_NS::CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
1867 		if(IsMsgHandled()) \
1868 			return TRUE; \
1869 	}
1870 
1871 #endif // (_WIN32_WINNT >= 0x0600)
1872 
1873 ///////////////////////////////////////////////////////////////////////////////
1874 // ATL defined messages
1875 
1876 // BOOL OnForwardMsg(LPMSG Msg, DWORD nUserData)
1877 #define MSG_WM_FORWARDMSG(func) \
1878 	if (uMsg == WM_FORWARDMSG) \
1879 	{ \
1880 		SetMsgHandled(TRUE); \
1881 		lResult = (LRESULT)func((LPMSG)lParam, (DWORD)wParam); \
1882 		if(IsMsgHandled()) \
1883 			return TRUE; \
1884 	}
1885 
1886 ///////////////////////////////////////////////////////////////////////////////
1887 // Dialog specific messages
1888 
1889 // LRESULT OnDMGetDefID()
1890 #define MSG_DM_GETDEFID(func) \
1891 	if (uMsg == DM_GETDEFID) \
1892 	{ \
1893 		SetMsgHandled(TRUE); \
1894 		lResult = func(); \
1895 		if(IsMsgHandled()) \
1896 			return TRUE; \
1897 	}
1898 
1899 // void OnDMSetDefID(UINT DefID)
1900 #define MSG_DM_SETDEFID(func) \
1901 	if (uMsg == DM_SETDEFID) \
1902 	{ \
1903 		SetMsgHandled(TRUE); \
1904 		func((UINT)wParam); \
1905 		lResult = TRUE; \
1906 		if(IsMsgHandled()) \
1907 			return TRUE; \
1908 	}
1909 
1910 // void OnDMReposition()
1911 #define MSG_DM_REPOSITION(func) \
1912 	if (uMsg == DM_REPOSITION) \
1913 	{ \
1914 		SetMsgHandled(TRUE); \
1915 		func(); \
1916 		lResult = 0; \
1917 		if(IsMsgHandled()) \
1918 			return TRUE; \
1919 	}
1920 
1921 ///////////////////////////////////////////////////////////////////////////////
1922 // Reflected messages
1923 
1924 // void OnReflectedCommand(UINT uNotifyCode, int nID, CWindow wndCtl)
1925 #define MSG_OCM_COMMAND(func) \
1926 	if (uMsg == OCM_COMMAND) \
1927 	{ \
1928 		SetMsgHandled(TRUE); \
1929 		func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
1930 		lResult = 0; \
1931 		if(IsMsgHandled()) \
1932 			return TRUE; \
1933 	}
1934 
1935 // LRESULT OnReflectedNotify(int idCtrl, LPNMHDR pnmh)
1936 #define MSG_OCM_NOTIFY(func) \
1937 	if (uMsg == OCM_NOTIFY) \
1938 	{ \
1939 		SetMsgHandled(TRUE); \
1940 		lResult = func((int)wParam, (LPNMHDR)lParam); \
1941 		if(IsMsgHandled()) \
1942 			return TRUE; \
1943 	}
1944 
1945 // void OnReflectedParentNotify(UINT message, UINT nChildID, LPARAM lParam)
1946 #define MSG_OCM_PARENTNOTIFY(func) \
1947 	if (uMsg == OCM_PARENTNOTIFY) \
1948 	{ \
1949 		SetMsgHandled(TRUE); \
1950 		func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \
1951 		lResult = 0; \
1952 		if(IsMsgHandled()) \
1953 			return TRUE; \
1954 	}
1955 
1956 // void OnReflectedDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
1957 #define MSG_OCM_DRAWITEM(func) \
1958 	if (uMsg == OCM_DRAWITEM) \
1959 	{ \
1960 		SetMsgHandled(TRUE); \
1961 		func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \
1962 		lResult = TRUE; \
1963 		if(IsMsgHandled()) \
1964 			return TRUE; \
1965 	}
1966 
1967 // void OnReflectedMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
1968 #define MSG_OCM_MEASUREITEM(func) \
1969 	if (uMsg == OCM_MEASUREITEM) \
1970 	{ \
1971 		SetMsgHandled(TRUE); \
1972 		func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \
1973 		lResult = TRUE; \
1974 		if(IsMsgHandled()) \
1975 			return TRUE; \
1976 	}
1977 
1978 // int OnReflectedCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct)
1979 #define MSG_OCM_COMPAREITEM(func) \
1980 	if (uMsg == OCM_COMPAREITEM) \
1981 	{ \
1982 		SetMsgHandled(TRUE); \
1983 		lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \
1984 		if(IsMsgHandled()) \
1985 			return TRUE; \
1986 	}
1987 
1988 // void OnReflectedDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct)
1989 #define MSG_OCM_DELETEITEM(func) \
1990 	if (uMsg == OCM_DELETEITEM) \
1991 	{ \
1992 		SetMsgHandled(TRUE); \
1993 		func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \
1994 		lResult = TRUE; \
1995 		if(IsMsgHandled()) \
1996 			return TRUE; \
1997 	}
1998 
1999 // int OnReflectedVKeyToItem(UINT nKey, UINT nIndex, CListBox listBox)
2000 #define MSG_OCM_VKEYTOITEM(func) \
2001 	if (uMsg == OCM_VKEYTOITEM) \
2002 	{ \
2003 		SetMsgHandled(TRUE); \
2004 		lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
2005 		if(IsMsgHandled()) \
2006 			return TRUE; \
2007 	}
2008 
2009 //int OnReflectedCharToItem(UINT nChar, UINT nIndex, CListBox listBox)
2010 #define MSG_OCM_CHARTOITEM(func) \
2011 	if (uMsg == OCM_CHARTOITEM) \
2012 	{ \
2013 		SetMsgHandled(TRUE); \
2014 		lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
2015 		if(IsMsgHandled()) \
2016 			return TRUE; \
2017 	}
2018 
2019 // void OnReflectedHScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
2020 #define MSG_OCM_HSCROLL(func) \
2021 	if (uMsg == OCM_HSCROLL) \
2022 	{ \
2023 		SetMsgHandled(TRUE); \
2024 		func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
2025 		lResult = 0; \
2026 		if(IsMsgHandled()) \
2027 			return TRUE; \
2028 	}
2029 
2030 // void OnReflectedVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
2031 #define MSG_OCM_VSCROLL(func) \
2032 	if (uMsg == OCM_VSCROLL) \
2033 	{ \
2034 		SetMsgHandled(TRUE); \
2035 		func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
2036 		lResult = 0; \
2037 		if(IsMsgHandled()) \
2038 			return TRUE; \
2039 	}
2040 
2041 // HBRUSH OnReflectedCtlColorEdit(CDCHandle dc, CEdit edit)
2042 #define MSG_OCM_CTLCOLOREDIT(func) \
2043 	if (uMsg == OCM_CTLCOLOREDIT) \
2044 	{ \
2045 		SetMsgHandled(TRUE); \
2046 		lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
2047 		if(IsMsgHandled()) \
2048 			return TRUE; \
2049 	}
2050 
2051 // HBRUSH OnReflectedCtlColorListBox(CDCHandle dc, CListBox listBox)
2052 #define MSG_OCM_CTLCOLORLISTBOX(func) \
2053 	if (uMsg == OCM_CTLCOLORLISTBOX) \
2054 	{ \
2055 		SetMsgHandled(TRUE); \
2056 		lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
2057 		if(IsMsgHandled()) \
2058 			return TRUE; \
2059 	}
2060 
2061 // HBRUSH OnReflectedCtlColorBtn(CDCHandle dc, CButton button)
2062 #define MSG_OCM_CTLCOLORBTN(func) \
2063 	if (uMsg == OCM_CTLCOLORBTN) \
2064 	{ \
2065 		SetMsgHandled(TRUE); \
2066 		lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
2067 		if(IsMsgHandled()) \
2068 			return TRUE; \
2069 	}
2070 
2071 // HBRUSH OnReflectedCtlColorDlg(CDCHandle dc, CWindow wnd)
2072 #define MSG_OCM_CTLCOLORDLG(func) \
2073 	if (uMsg == OCM_CTLCOLORDLG) \
2074 	{ \
2075 		SetMsgHandled(TRUE); \
2076 		lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
2077 		if(IsMsgHandled()) \
2078 			return TRUE; \
2079 	}
2080 
2081 // HBRUSH OnReflectedCtlColorScrollBar(CDCHandle dc, CScrollBar scrollBar)
2082 #define MSG_OCM_CTLCOLORSCROLLBAR(func) \
2083 	if (uMsg == OCM_CTLCOLORSCROLLBAR) \
2084 	{ \
2085 		SetMsgHandled(TRUE); \
2086 		lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
2087 		if(IsMsgHandled()) \
2088 			return TRUE; \
2089 	}
2090 
2091 // HBRUSH OnReflectedCtlColorStatic(CDCHandle dc, CStatic wndStatic)
2092 #define MSG_OCM_CTLCOLORSTATIC(func) \
2093 	if (uMsg == OCM_CTLCOLORSTATIC) \
2094 	{ \
2095 		SetMsgHandled(TRUE); \
2096 		lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
2097 		if(IsMsgHandled()) \
2098 			return TRUE; \
2099 	}
2100 
2101 ///////////////////////////////////////////////////////////////////////////////
2102 // Edit specific messages
2103 
2104 // void OnClear()
2105 #define MSG_WM_CLEAR(func) \
2106 	if (uMsg == WM_CLEAR) \
2107 	{ \
2108 		SetMsgHandled(TRUE); \
2109 		func(); \
2110 		lResult = 0; \
2111 		if(IsMsgHandled()) \
2112 			return TRUE; \
2113 	}
2114 
2115 // void OnCopy()
2116 #define MSG_WM_COPY(func) \
2117 	if (uMsg == WM_COPY) \
2118 	{ \
2119 		SetMsgHandled(TRUE); \
2120 		func(); \
2121 		lResult = 0; \
2122 		if(IsMsgHandled()) \
2123 			return TRUE; \
2124 	}
2125 
2126 // void OnCut()
2127 #define MSG_WM_CUT(func) \
2128 	if (uMsg == WM_CUT) \
2129 	{ \
2130 		SetMsgHandled(TRUE); \
2131 		func(); \
2132 		lResult = 0; \
2133 		if(IsMsgHandled()) \
2134 			return TRUE; \
2135 	}
2136 
2137 // void OnPaste()
2138 #define MSG_WM_PASTE(func) \
2139 	if (uMsg == WM_PASTE) \
2140 	{ \
2141 		SetMsgHandled(TRUE); \
2142 		func(); \
2143 		lResult = 0; \
2144 		if(IsMsgHandled()) \
2145 			return TRUE; \
2146 	}
2147 
2148 // void OnUndo()
2149 #define MSG_WM_UNDO(func) \
2150 	if (uMsg == WM_UNDO) \
2151 	{ \
2152 		SetMsgHandled(TRUE); \
2153 		func(); \
2154 		lResult = 0; \
2155 		if(IsMsgHandled()) \
2156 			return TRUE; \
2157 	}
2158 
2159 ///////////////////////////////////////////////////////////////////////////////
2160 // Generic message handlers
2161 
2162 // LRESULT OnMessageHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam)
2163 #define MESSAGE_HANDLER_EX(msg, func) \
2164 	if(uMsg == msg) \
2165 	{ \
2166 		SetMsgHandled(TRUE); \
2167 		lResult = func(uMsg, wParam, lParam); \
2168 		if(IsMsgHandled()) \
2169 			return TRUE; \
2170 	}
2171 
2172 // LRESULT OnMessageRangeHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam)
2173 #define MESSAGE_RANGE_HANDLER_EX(msgFirst, msgLast, func) \
2174 	if(uMsg >= msgFirst && uMsg <= msgLast) \
2175 	{ \
2176 		SetMsgHandled(TRUE); \
2177 		lResult = func(uMsg, wParam, lParam); \
2178 		if(IsMsgHandled()) \
2179 			return TRUE; \
2180 	}
2181 
2182 ///////////////////////////////////////////////////////////////////////////////
2183 // Commands and notifications
2184 
2185 // void OnCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2186 #define COMMAND_HANDLER_EX(id, code, func) \
2187 	if (uMsg == WM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) \
2188 	{ \
2189 		SetMsgHandled(TRUE); \
2190 		func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2191 		lResult = 0; \
2192 		if(IsMsgHandled()) \
2193 			return TRUE; \
2194 	}
2195 
2196 // void OnCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2197 #define COMMAND_ID_HANDLER_EX(id, func) \
2198 	if (uMsg == WM_COMMAND && id == LOWORD(wParam)) \
2199 	{ \
2200 		SetMsgHandled(TRUE); \
2201 		func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2202 		lResult = 0; \
2203 		if(IsMsgHandled()) \
2204 			return TRUE; \
2205 	}
2206 
2207 // void OnCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2208 #define COMMAND_CODE_HANDLER_EX(code, func) \
2209 	if (uMsg == WM_COMMAND && code == HIWORD(wParam)) \
2210 	{ \
2211 		SetMsgHandled(TRUE); \
2212 		func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2213 		lResult = 0; \
2214 		if(IsMsgHandled()) \
2215 			return TRUE; \
2216 	}
2217 
2218 // LRESULT OnNotifyHandlerEX(LPNMHDR pnmh)
2219 #define NOTIFY_HANDLER_EX(id, cd, func) \
2220 	if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom) \
2221 	{ \
2222 		SetMsgHandled(TRUE); \
2223 		lResult = func((LPNMHDR)lParam); \
2224 		if(IsMsgHandled()) \
2225 			return TRUE; \
2226 	}
2227 
2228 // LRESULT OnNotifyIDHandlerEX(LPNMHDR pnmh)
2229 #define NOTIFY_ID_HANDLER_EX(id, func) \
2230 	if (uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \
2231 	{ \
2232 		SetMsgHandled(TRUE); \
2233 		lResult = func((LPNMHDR)lParam); \
2234 		if(IsMsgHandled()) \
2235 			return TRUE; \
2236 	}
2237 
2238 // LRESULT OnNotifyCodeHandlerEX(LPNMHDR pnmh)
2239 #define NOTIFY_CODE_HANDLER_EX(cd, func) \
2240 	if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \
2241 	{ \
2242 		SetMsgHandled(TRUE); \
2243 		lResult = func((LPNMHDR)lParam); \
2244 		if(IsMsgHandled()) \
2245 			return TRUE; \
2246 	}
2247 
2248 // void OnCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2249 #define COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \
2250 	if(uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
2251 	{ \
2252 		SetMsgHandled(TRUE); \
2253 		func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2254 		lResult = 0; \
2255 		if(IsMsgHandled()) \
2256 			return TRUE; \
2257 	}
2258 
2259 // void OnCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2260 #define COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \
2261 	if(uMsg == WM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
2262 	{ \
2263 		SetMsgHandled(TRUE); \
2264 		func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2265 		lResult = 0; \
2266 		if(IsMsgHandled()) \
2267 			return TRUE; \
2268 	}
2269 
2270 // LRESULT OnNotifyRangeHandlerEX(LPNMHDR pnmh)
2271 #define NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \
2272 	if(uMsg == WM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
2273 	{ \
2274 		SetMsgHandled(TRUE); \
2275 		lResult = func((LPNMHDR)lParam); \
2276 		if(IsMsgHandled()) \
2277 			return TRUE; \
2278 	}
2279 
2280 // LRESULT OnNotifyRangeCodeHandlerEX(LPNMHDR pnmh)
2281 #define NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \
2282 	if(uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
2283 	{ \
2284 		SetMsgHandled(TRUE); \
2285 		lResult = func((LPNMHDR)lParam); \
2286 		if(IsMsgHandled()) \
2287 			return TRUE; \
2288 	}
2289 
2290 // LRESULT OnReflectedCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2291 #define REFLECTED_COMMAND_HANDLER_EX(id, code, func) \
2292 	if (uMsg == OCM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) \
2293 	{ \
2294 		SetMsgHandled(TRUE); \
2295 		func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2296 		lResult = 0; \
2297 		if(IsMsgHandled()) \
2298 			return TRUE; \
2299 	}
2300 
2301 // LRESULT OnReflectedCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2302 #define REFLECTED_COMMAND_ID_HANDLER_EX(id, func) \
2303 	if (uMsg == OCM_COMMAND && id == LOWORD(wParam)) \
2304 	{ \
2305 		SetMsgHandled(TRUE); \
2306 		func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2307 		lResult = 0; \
2308 		if(IsMsgHandled()) \
2309 			return TRUE; \
2310 	}
2311 
2312 // LRESULT OnReflectedCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2313 #define REFLECTED_COMMAND_CODE_HANDLER_EX(code, func) \
2314 	if (uMsg == OCM_COMMAND && code == HIWORD(wParam)) \
2315 	{ \
2316 		SetMsgHandled(TRUE); \
2317 		func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2318 		lResult = 0; \
2319 		if(IsMsgHandled()) \
2320 			return TRUE; \
2321 	}
2322 
2323 // LRESULT OnReflectedNotifyHandlerEX(LPNMHDR pnmh)
2324 #define REFLECTED_NOTIFY_HANDLER_EX(id, cd, func) \
2325 	if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom) \
2326 	{ \
2327 		SetMsgHandled(TRUE); \
2328 		lResult = func((LPNMHDR)lParam); \
2329 		if(IsMsgHandled()) \
2330 			return TRUE; \
2331 	}
2332 
2333 // LRESULT OnReflectedNotifyIDHandlerEX(LPNMHDR pnmh)
2334 #define REFLECTED_NOTIFY_ID_HANDLER_EX(id, func) \
2335 	if (uMsg == OCM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \
2336 	{ \
2337 		SetMsgHandled(TRUE); \
2338 		lResult = func((LPNMHDR)lParam); \
2339 		if(IsMsgHandled()) \
2340 			return TRUE; \
2341 	}
2342 
2343 // LRESULT OnReflectedNotifyCodeHandlerEX(LPNMHDR pnmh)
2344 #define REFLECTED_NOTIFY_CODE_HANDLER_EX(cd, func) \
2345 	if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \
2346 	{ \
2347 		SetMsgHandled(TRUE); \
2348 		lResult = func((LPNMHDR)lParam); \
2349 		if(IsMsgHandled()) \
2350 			return TRUE; \
2351 	}
2352 
2353 // void OnReflectedCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2354 #define REFLECTED_COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \
2355 	if(uMsg == OCM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
2356 	{ \
2357 		SetMsgHandled(TRUE); \
2358 		func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2359 		lResult = 0; \
2360 		if(IsMsgHandled()) \
2361 			return TRUE; \
2362 	}
2363 
2364 // void OnReflectedCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2365 #define REFLECTED_COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \
2366 	if(uMsg == OCM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
2367 	{ \
2368 		SetMsgHandled(TRUE); \
2369 		func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2370 		lResult = 0; \
2371 		if(IsMsgHandled()) \
2372 			return TRUE; \
2373 	}
2374 
2375 // LRESULT OnReflectedNotifyRangeHandlerEX(LPNMHDR pnmh)
2376 #define REFLECTED_NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \
2377 	if(uMsg == OCM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
2378 	{ \
2379 		SetMsgHandled(TRUE); \
2380 		lResult = func((LPNMHDR)lParam); \
2381 		if(IsMsgHandled()) \
2382 			return TRUE; \
2383 	}
2384 
2385 // LRESULT OnReflectedNotifyRangeCodeHandlerEX(LPNMHDR pnmh)
2386 #define REFLECTED_NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \
2387 	if(uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
2388 	{ \
2389 		SetMsgHandled(TRUE); \
2390 		lResult = func((LPNMHDR)lParam); \
2391 		if(IsMsgHandled()) \
2392 			return TRUE; \
2393 	}
2394 
2395 #endif // __ATLCRACK_H__
2396