1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef UI_GFX_WIN_MSG_UTIL_H_
6 #define UI_GFX_WIN_MSG_UTIL_H_
8 #include "base/logging.h"
9 #include "ui/gfx/geometry/point.h"
10 #include "ui/gfx/geometry/size.h"
12 // Based on WTL version 8.0 atlcrack.h
14 // This differs from the original atlcrack.h by removing usage of CPoint,
17 ///////////////////////////////////////////////////////////////////////////////
18 // Message map macro for cracked handlers
20 // Note about message maps with cracked handlers:
21 // For ATL 3.0, a message map using cracked handlers MUST use BEGIN_MSG_MAP_EX.
22 // For ATL 7.0 or higher, you can use BEGIN_MSG_MAP for CWindowImpl/CDialogImpl
24 // but must use BEGIN_MSG_MAP_EX for classes that don't derive from
25 // CWindowImpl/CDialogImpl.
27 #define CR_BEGIN_MSG_MAP_EX(theClass) \
30 /* "handled" management for cracked handlers */ \
31 BOOL IsMsgHandled() const { return m_bMsgHandled; } \
32 void SetMsgHandled(BOOL bHandled) { m_bMsgHandled = bHandled; } \
33 BOOL ProcessWindowMessage(HWND hWnd, \
38 DWORD dwMsgMapID = 0) { \
39 BOOL bOldMsgHandled = m_bMsgHandled; \
40 BOOL bRet = _ProcessWindowMessage( \
41 hWnd, uMsg, wParam, lParam, lResult, dwMsgMapID); \
42 m_bMsgHandled = bOldMsgHandled; \
45 BOOL _ProcessWindowMessage(HWND hWnd, \
51 BOOL bHandled = TRUE; \
58 switch (dwMsgMapID) { \
61 // Replacement for atlwin.h's END_MSG_MAP for removing ATL usage.
62 #define CR_END_MSG_MAP() \
65 NOTREACHED() << "Invalid message map ID: " << dwMsgMapID; \
71 #define CR_GET_X_LPARAM(lParam) ((int)(short)LOWORD(lParam))
72 #define CR_GET_Y_LPARAM(lParam) ((int)(short)HIWORD(lParam))
74 ///////////////////////////////////////////////////////////////////////////////
75 // Standard Windows message macros
77 // int OnCreate(LPCREATESTRUCT lpCreateStruct)
78 #define CR_MSG_WM_CREATE(func) \
79 if (uMsg == WM_CREATE) { \
80 SetMsgHandled(TRUE); \
81 lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \
86 // BOOL OnInitDialog(CWindow wndFocus, LPARAM lInitParam)
87 #define CR_MSG_WM_INITDIALOG(func) \
88 if (uMsg == WM_INITDIALOG) { \
89 SetMsgHandled(TRUE); \
90 lResult = (LRESULT)func((HWND)wParam, lParam); \
95 // BOOL OnCopyData(CWindow wnd, PCOPYDATASTRUCT pCopyDataStruct)
96 #define CR_MSG_WM_COPYDATA(func) \
97 if (uMsg == WM_COPYDATA) { \
98 SetMsgHandled(TRUE); \
99 lResult = (LRESULT)func((HWND)wParam, (PCOPYDATASTRUCT)lParam); \
100 if (IsMsgHandled()) \
105 #define CR_MSG_WM_DESTROY(func) \
106 if (uMsg == WM_DESTROY) { \
107 SetMsgHandled(TRUE); \
110 if (IsMsgHandled()) \
114 // void OnMove(CPoint ptPos)
115 #define CR_MSG_WM_MOVE(func) \
116 if (uMsg == WM_MOVE) { \
117 SetMsgHandled(TRUE); \
118 func(gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
120 if (IsMsgHandled()) \
124 // void OnSize(UINT nType, gfx::Size size)
125 #define CR_MSG_WM_SIZE(func) \
126 if (uMsg == WM_SIZE) { \
127 SetMsgHandled(TRUE); \
129 gfx::Size(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
131 if (IsMsgHandled()) \
135 // void OnActivate(UINT nState, BOOL bMinimized, CWindow wndOther)
136 #define CR_MSG_WM_ACTIVATE(func) \
137 if (uMsg == WM_ACTIVATE) { \
138 SetMsgHandled(TRUE); \
139 func((UINT)LOWORD(wParam), (BOOL)HIWORD(wParam), (HWND)lParam); \
141 if (IsMsgHandled()) \
145 // void OnSetFocus(CWindow wndOld)
146 #define CR_MSG_WM_SETFOCUS(func) \
147 if (uMsg == WM_SETFOCUS) { \
148 SetMsgHandled(TRUE); \
149 func((HWND)wParam); \
151 if (IsMsgHandled()) \
155 // void OnKillFocus(CWindow wndFocus)
156 #define CR_MSG_WM_KILLFOCUS(func) \
157 if (uMsg == WM_KILLFOCUS) { \
158 SetMsgHandled(TRUE); \
159 func((HWND)wParam); \
161 if (IsMsgHandled()) \
165 // void OnEnable(BOOL bEnable)
166 #define CR_MSG_WM_ENABLE(func) \
167 if (uMsg == WM_ENABLE) { \
168 SetMsgHandled(TRUE); \
169 func((BOOL)wParam); \
171 if (IsMsgHandled()) \
175 // void OnPaint(CDCHandle dc)
176 #define CR_MSG_WM_PAINT(func) \
177 if (uMsg == WM_PAINT) { \
178 SetMsgHandled(TRUE); \
181 if (IsMsgHandled()) \
186 #define CR_MSG_WM_CLOSE(func) \
187 if (uMsg == WM_CLOSE) { \
188 SetMsgHandled(TRUE); \
191 if (IsMsgHandled()) \
195 // BOOL OnQueryEndSession(UINT nSource, UINT uLogOff)
196 #define CR_MSG_WM_QUERYENDSESSION(func) \
197 if (uMsg == WM_QUERYENDSESSION) { \
198 SetMsgHandled(TRUE); \
199 lResult = (LRESULT)func((UINT)wParam, (UINT)lParam); \
200 if (IsMsgHandled()) \
204 // BOOL OnQueryOpen()
205 #define CR_MSG_WM_QUERYOPEN(func) \
206 if (uMsg == WM_QUERYOPEN) { \
207 SetMsgHandled(TRUE); \
208 lResult = (LRESULT)func(); \
209 if (IsMsgHandled()) \
213 // BOOL OnEraseBkgnd(CDCHandle dc)
214 #define CR_MSG_WM_ERASEBKGND(func) \
215 if (uMsg == WM_ERASEBKGND) { \
216 SetMsgHandled(TRUE); \
217 lResult = (LRESULT)func((HDC)wParam); \
218 if (IsMsgHandled()) \
222 // void OnSysColorChange()
223 #define CR_MSG_WM_SYSCOLORCHANGE(func) \
224 if (uMsg == WM_SYSCOLORCHANGE) { \
225 SetMsgHandled(TRUE); \
228 if (IsMsgHandled()) \
232 // void OnEndSession(BOOL bEnding, UINT uLogOff)
233 #define CR_MSG_WM_ENDSESSION(func) \
234 if (uMsg == WM_ENDSESSION) { \
235 SetMsgHandled(TRUE); \
236 func((BOOL)wParam, (UINT)lParam); \
238 if (IsMsgHandled()) \
242 // void OnShowWindow(BOOL bShow, UINT nStatus)
243 #define CR_MSG_WM_SHOWWINDOW(func) \
244 if (uMsg == WM_SHOWWINDOW) { \
245 SetMsgHandled(TRUE); \
246 func((BOOL)wParam, (int)lParam); \
248 if (IsMsgHandled()) \
252 // HBRUSH OnCtlColorEdit(CDCHandle dc, CEdit edit)
253 #define CR_MSG_WM_CTLCOLOREDIT(func) \
254 if (uMsg == WM_CTLCOLOREDIT) { \
255 SetMsgHandled(TRUE); \
256 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
257 if (IsMsgHandled()) \
261 // HBRUSH OnCtlColorListBox(CDCHandle dc, CListBox listBox)
262 #define CR_MSG_WM_CTLCOLORLISTBOX(func) \
263 if (uMsg == WM_CTLCOLORLISTBOX) { \
264 SetMsgHandled(TRUE); \
265 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
266 if (IsMsgHandled()) \
270 // HBRUSH OnCtlColorBtn(CDCHandle dc, CButton button)
271 #define CR_MSG_WM_CTLCOLORBTN(func) \
272 if (uMsg == WM_CTLCOLORBTN) { \
273 SetMsgHandled(TRUE); \
274 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
275 if (IsMsgHandled()) \
279 // HBRUSH OnCtlColorDlg(CDCHandle dc, CWindow wnd)
280 #define CR_MSG_WM_CTLCOLORDLG(func) \
281 if (uMsg == WM_CTLCOLORDLG) { \
282 SetMsgHandled(TRUE); \
283 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
284 if (IsMsgHandled()) \
288 // HBRUSH OnCtlColorScrollBar(CDCHandle dc, CScrollBar scrollBar)
289 #define CR_MSG_WM_CTLCOLORSCROLLBAR(func) \
290 if (uMsg == WM_CTLCOLORSCROLLBAR) { \
291 SetMsgHandled(TRUE); \
292 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
293 if (IsMsgHandled()) \
297 // HBRUSH OnCtlColorStatic(CDCHandle dc, CStatic wndStatic)
298 #define CR_MSG_WM_CTLCOLORSTATIC(func) \
299 if (uMsg == WM_CTLCOLORSTATIC) { \
300 SetMsgHandled(TRUE); \
301 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
302 if (IsMsgHandled()) \
306 // void OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
307 #define CR_MSG_WM_SETTINGCHANGE(func) \
308 if (uMsg == WM_SETTINGCHANGE) { \
309 SetMsgHandled(TRUE); \
310 func((UINT)wParam, (LPCTSTR)lParam); \
312 if (IsMsgHandled()) \
316 // void OnDevModeChange(LPCTSTR lpDeviceName)
317 #define CR_MSG_WM_DEVMODECHANGE(func) \
318 if (uMsg == WM_DEVMODECHANGE) { \
319 SetMsgHandled(TRUE); \
320 func((LPCTSTR)lParam); \
322 if (IsMsgHandled()) \
326 // void OnActivateApp(BOOL bActive, DWORD dwThreadID)
327 #define CR_MSG_WM_ACTIVATEAPP(func) \
328 if (uMsg == WM_ACTIVATEAPP) { \
329 SetMsgHandled(TRUE); \
330 func((BOOL)wParam, (DWORD)lParam); \
332 if (IsMsgHandled()) \
336 // void OnFontChange()
337 #define CR_MSG_WM_FONTCHANGE(func) \
338 if (uMsg == WM_FONTCHANGE) { \
339 SetMsgHandled(TRUE); \
342 if (IsMsgHandled()) \
346 // void OnTimeChange()
347 #define CR_MSG_WM_TIMECHANGE(func) \
348 if (uMsg == WM_TIMECHANGE) { \
349 SetMsgHandled(TRUE); \
352 if (IsMsgHandled()) \
356 // void OnCancelMode()
357 #define CR_MSG_WM_CANCELMODE(func) \
358 if (uMsg == WM_CANCELMODE) { \
359 SetMsgHandled(TRUE); \
362 if (IsMsgHandled()) \
366 // BOOL OnSetCursor(CWindow wnd, UINT nHitTest, UINT message)
367 #define CR_MSG_WM_SETCURSOR(func) \
368 if (uMsg == WM_SETCURSOR) { \
369 SetMsgHandled(TRUE); \
370 lResult = (LRESULT)func( \
371 (HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
372 if (IsMsgHandled()) \
376 // int OnMouseActivate(CWindow wndTopLevel, UINT nHitTest, UINT message)
377 #define CR_MSG_WM_MOUSEACTIVATE(func) \
378 if (uMsg == WM_MOUSEACTIVATE) { \
379 SetMsgHandled(TRUE); \
380 lResult = (LRESULT)func( \
381 (HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
382 if (IsMsgHandled()) \
386 // void OnChildActivate()
387 #define CR_MSG_WM_CHILDACTIVATE(func) \
388 if (uMsg == WM_CHILDACTIVATE) { \
389 SetMsgHandled(TRUE); \
392 if (IsMsgHandled()) \
396 // void OnGetMinMaxInfo(LPMINMAXINFO lpMMI)
397 #define CR_MSG_WM_GETMINMAXINFO(func) \
398 if (uMsg == WM_GETMINMAXINFO) { \
399 SetMsgHandled(TRUE); \
400 func((LPMINMAXINFO)lParam); \
402 if (IsMsgHandled()) \
406 // void OnIconEraseBkgnd(CDCHandle dc)
407 #define CR_MSG_WM_ICONERASEBKGND(func) \
408 if (uMsg == WM_ICONERASEBKGND) { \
409 SetMsgHandled(TRUE); \
412 if (IsMsgHandled()) \
416 // void OnSpoolerStatus(UINT nStatus, UINT nJobs)
417 #define CR_MSG_WM_SPOOLERSTATUS(func) \
418 if (uMsg == WM_SPOOLERSTATUS) { \
419 SetMsgHandled(TRUE); \
420 func((UINT)wParam, (UINT)LOWORD(lParam)); \
422 if (IsMsgHandled()) \
426 // void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
427 #define CR_MSG_WM_DRAWITEM(func) \
428 if (uMsg == WM_DRAWITEM) { \
429 SetMsgHandled(TRUE); \
430 func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \
432 if (IsMsgHandled()) \
436 // void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct)
437 #define CR_MSG_WM_MEASUREITEM(func) \
438 if (uMsg == WM_MEASUREITEM) { \
439 SetMsgHandled(TRUE); \
440 func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \
442 if (IsMsgHandled()) \
446 // void OnDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct)
447 #define CR_MSG_WM_DELETEITEM(func) \
448 if (uMsg == WM_DELETEITEM) { \
449 SetMsgHandled(TRUE); \
450 func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \
452 if (IsMsgHandled()) \
456 // int OnCharToItem(UINT nChar, UINT nIndex, CListBox listBox)
457 #define CR_MSG_WM_CHARTOITEM(func) \
458 if (uMsg == WM_CHARTOITEM) { \
459 SetMsgHandled(TRUE); \
460 lResult = (LRESULT)func( \
461 (UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
462 if (IsMsgHandled()) \
466 // int OnVKeyToItem(UINT nKey, UINT nIndex, CListBox listBox)
467 #define CR_MSG_WM_VKEYTOITEM(func) \
468 if (uMsg == WM_VKEYTOITEM) { \
469 SetMsgHandled(TRUE); \
470 lResult = (LRESULT)func( \
471 (UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
472 if (IsMsgHandled()) \
476 // HCURSOR OnQueryDragIcon()
477 #define CR_MSG_WM_QUERYDRAGICON(func) \
478 if (uMsg == WM_QUERYDRAGICON) { \
479 SetMsgHandled(TRUE); \
480 lResult = (LRESULT)func(); \
481 if (IsMsgHandled()) \
485 // int OnCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct)
486 #define CR_MSG_WM_COMPAREITEM(func) \
487 if (uMsg == WM_COMPAREITEM) { \
488 SetMsgHandled(TRUE); \
489 lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \
490 if (IsMsgHandled()) \
494 // void OnCompacting(UINT nCpuTime)
495 #define CR_MSG_WM_COMPACTING(func) \
496 if (uMsg == WM_COMPACTING) { \
497 SetMsgHandled(TRUE); \
498 func((UINT)wParam); \
500 if (IsMsgHandled()) \
504 // BOOL OnNcCreate(LPCREATESTRUCT lpCreateStruct)
505 #define CR_MSG_WM_NCCREATE(func) \
506 if (uMsg == WM_NCCREATE) { \
507 SetMsgHandled(TRUE); \
508 lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \
509 if (IsMsgHandled()) \
513 // void OnNcDestroy()
514 #define CR_MSG_WM_NCDESTROY(func) \
515 if (uMsg == WM_NCDESTROY) { \
516 SetMsgHandled(TRUE); \
519 if (IsMsgHandled()) \
523 // LRESULT OnNcCalcSize(BOOL bCalcValidRects, LPARAM lParam)
524 #define CR_MSG_WM_NCCALCSIZE(func) \
525 if (uMsg == WM_NCCALCSIZE) { \
526 SetMsgHandled(TRUE); \
527 lResult = func((BOOL)wParam, lParam); \
528 if (IsMsgHandled()) \
532 // UINT OnNcHitTest(gfx::Point point)
533 #define CR_MSG_WM_NCHITTEST(func) \
534 if (uMsg == WM_NCHITTEST) { \
535 SetMsgHandled(TRUE); \
536 lResult = (LRESULT)func( \
537 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
538 if (IsMsgHandled()) \
542 // void OnNcPaint(CRgn rgn)
543 #define CR_MSG_WM_NCPAINT(func) \
544 if (uMsg == WM_NCPAINT) { \
545 SetMsgHandled(TRUE); \
546 func((HRGN)wParam); \
548 if (IsMsgHandled()) \
552 // BOOL OnNcActivate(BOOL bActive)
553 #define CR_MSG_WM_NCACTIVATE(func) \
554 if (uMsg == WM_NCACTIVATE) { \
555 SetMsgHandled(TRUE); \
556 lResult = (LRESULT)func((BOOL)wParam); \
557 if (IsMsgHandled()) \
561 // UINT OnGetDlgCode(LPMSG lpMsg)
562 #define CR_MSG_WM_GETDLGCODE(func) \
563 if (uMsg == WM_GETDLGCODE) { \
564 SetMsgHandled(TRUE); \
565 lResult = (LRESULT)func((LPMSG)lParam); \
566 if (IsMsgHandled()) \
570 // void OnNcMouseMove(UINT nHitTest, gfx::Point point)
571 #define CR_MSG_WM_NCMOUSEMOVE(func) \
572 if (uMsg == WM_NCMOUSEMOVE) { \
573 SetMsgHandled(TRUE); \
575 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
577 if (IsMsgHandled()) \
581 // void OnNcLButtonDown(UINT nHitTest, gfx::Point point)
582 #define CR_MSG_WM_NCLBUTTONDOWN(func) \
583 if (uMsg == WM_NCLBUTTONDOWN) { \
584 SetMsgHandled(TRUE); \
586 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
588 if (IsMsgHandled()) \
592 // void OnNcLButtonUp(UINT nHitTest, gfx::Point point)
593 #define CR_MSG_WM_NCLBUTTONUP(func) \
594 if (uMsg == WM_NCLBUTTONUP) { \
595 SetMsgHandled(TRUE); \
597 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
599 if (IsMsgHandled()) \
603 // void OnNcLButtonDblClk(UINT nHitTest, gfx::Point point)
604 #define CR_MSG_WM_NCLBUTTONDBLCLK(func) \
605 if (uMsg == WM_NCLBUTTONDBLCLK) { \
606 SetMsgHandled(TRUE); \
608 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
610 if (IsMsgHandled()) \
614 // void OnNcRButtonDown(UINT nHitTest, gfx::Point point)
615 #define CR_MSG_WM_NCRBUTTONDOWN(func) \
616 if (uMsg == WM_NCRBUTTONDOWN) { \
617 SetMsgHandled(TRUE); \
619 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
621 if (IsMsgHandled()) \
625 // void OnNcRButtonUp(UINT nHitTest, gfx::Point point)
626 #define CR_MSG_WM_NCRBUTTONUP(func) \
627 if (uMsg == WM_NCRBUTTONUP) { \
628 SetMsgHandled(TRUE); \
630 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
632 if (IsMsgHandled()) \
636 // void OnNcRButtonDblClk(UINT nHitTest, CPoint point)
637 #define CR_MSG_WM_NCRBUTTONDBLCLK(func) \
638 if (uMsg == WM_NCRBUTTONDBLCLK) { \
639 SetMsgHandled(TRUE); \
641 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
643 if (IsMsgHandled()) \
647 // void OnNcMButtonDown(UINT nHitTest, CPoint point)
648 #define CR_MSG_WM_NCMBUTTONDOWN(func) \
649 if (uMsg == WM_NCMBUTTONDOWN) { \
650 SetMsgHandled(TRUE); \
652 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
654 if (IsMsgHandled()) \
658 // void OnNcMButtonUp(UINT nHitTest, CPoint point)
659 #define CR_MSG_WM_NCMBUTTONUP(func) \
660 if (uMsg == WM_NCMBUTTONUP) { \
661 SetMsgHandled(TRUE); \
663 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
665 if (IsMsgHandled()) \
669 // void OnNcMButtonDblClk(UINT nHitTest, CPoint point)
670 #define CR_MSG_WM_NCMBUTTONDBLCLK(func) \
671 if (uMsg == WM_NCMBUTTONDBLCLK) { \
672 SetMsgHandled(TRUE); \
674 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
676 if (IsMsgHandled()) \
680 // void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
681 #define CR_MSG_WM_KEYDOWN(func) \
682 if (uMsg == WM_KEYDOWN) { \
683 SetMsgHandled(TRUE); \
684 func((TCHAR)wParam, \
685 (UINT)lParam & 0xFFFF, \
686 (UINT)((lParam & 0xFFFF0000) >> 16)); \
688 if (IsMsgHandled()) \
692 // void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
693 #define CR_MSG_WM_KEYUP(func) \
694 if (uMsg == WM_KEYUP) { \
695 SetMsgHandled(TRUE); \
696 func((TCHAR)wParam, \
697 (UINT)lParam & 0xFFFF, \
698 (UINT)((lParam & 0xFFFF0000) >> 16)); \
700 if (IsMsgHandled()) \
704 // void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
705 #define CR_MSG_WM_CHAR(func) \
706 if (uMsg == WM_CHAR) { \
707 SetMsgHandled(TRUE); \
708 func((TCHAR)wParam, \
709 (UINT)lParam & 0xFFFF, \
710 (UINT)((lParam & 0xFFFF0000) >> 16)); \
712 if (IsMsgHandled()) \
716 // void OnDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags)
717 #define CR_MSG_WM_DEADCHAR(func) \
718 if (uMsg == WM_DEADCHAR) { \
719 SetMsgHandled(TRUE); \
720 func((TCHAR)wParam, \
721 (UINT)lParam & 0xFFFF, \
722 (UINT)((lParam & 0xFFFF0000) >> 16)); \
724 if (IsMsgHandled()) \
728 // void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
729 #define CR_MSG_WM_SYSKEYDOWN(func) \
730 if (uMsg == WM_SYSKEYDOWN) { \
731 SetMsgHandled(TRUE); \
732 func((TCHAR)wParam, \
733 (UINT)lParam & 0xFFFF, \
734 (UINT)((lParam & 0xFFFF0000) >> 16)); \
736 if (IsMsgHandled()) \
740 // void OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
741 #define CR_MSG_WM_SYSKEYUP(func) \
742 if (uMsg == WM_SYSKEYUP) { \
743 SetMsgHandled(TRUE); \
744 func((TCHAR)wParam, \
745 (UINT)lParam & 0xFFFF, \
746 (UINT)((lParam & 0xFFFF0000) >> 16)); \
748 if (IsMsgHandled()) \
752 // void OnSysChar(UINT nChar, UINT nRepCnt, UINT nFlags)
753 #define CR_MSG_WM_SYSCHAR(func) \
754 if (uMsg == WM_SYSCHAR) { \
755 SetMsgHandled(TRUE); \
756 func((TCHAR)wParam, \
757 (UINT)lParam & 0xFFFF, \
758 (UINT)((lParam & 0xFFFF0000) >> 16)); \
760 if (IsMsgHandled()) \
764 // void OnSysDeadChar(UINT nChar, UINT nRepCnt, UINT nFlags)
765 #define CR_MSG_WM_SYSDEADCHAR(func) \
766 if (uMsg == WM_SYSDEADCHAR) { \
767 SetMsgHandled(TRUE); \
768 func((TCHAR)wParam, \
769 (UINT)lParam & 0xFFFF, \
770 (UINT)((lParam & 0xFFFF0000) >> 16)); \
772 if (IsMsgHandled()) \
776 // void OnSysCommand(UINT nID, LPARAM lParam)
777 #define CR_MSG_WM_SYSCOMMAND(func) \
778 if (uMsg == WM_SYSCOMMAND) { \
779 SetMsgHandled(TRUE); \
781 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
783 if (IsMsgHandled()) \
787 // void OnTCard(UINT idAction, DWORD dwActionData)
788 #define CR_MSG_WM_TCARD(func) \
789 if (uMsg == WM_TCARD) { \
790 SetMsgHandled(TRUE); \
791 func((UINT)wParam, (DWORD)lParam); \
793 if (IsMsgHandled()) \
797 // void OnTimer(UINT_PTR nIDEvent)
798 #define CR_MSG_WM_TIMER(func) \
799 if (uMsg == WM_TIMER) { \
800 SetMsgHandled(TRUE); \
801 func((UINT_PTR)wParam); \
803 if (IsMsgHandled()) \
807 // void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
808 #define CR_MSG_WM_HSCROLL(func) \
809 if (uMsg == WM_HSCROLL) { \
810 SetMsgHandled(TRUE); \
811 func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
813 if (IsMsgHandled()) \
817 // void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
818 #define CR_MSG_WM_VSCROLL(func) \
819 if (uMsg == WM_VSCROLL) { \
820 SetMsgHandled(TRUE); \
821 func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
823 if (IsMsgHandled()) \
827 // void OnInitMenu(CMenu menu)
828 #define CR_MSG_WM_INITMENU(func) \
829 if (uMsg == WM_INITMENU) { \
830 SetMsgHandled(TRUE); \
831 func((HMENU)wParam); \
833 if (IsMsgHandled()) \
837 // void OnInitMenuPopup(CMenu menuPopup, UINT nIndex, BOOL bSysMenu)
838 #define CR_MSG_WM_INITMENUPOPUP(func) \
839 if (uMsg == WM_INITMENUPOPUP) { \
840 SetMsgHandled(TRUE); \
841 func((HMENU)wParam, (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam)); \
843 if (IsMsgHandled()) \
847 // void OnMenuSelect(UINT nItemID, UINT nFlags, CMenu menu)
848 #define CR_MSG_WM_MENUSELECT(func) \
849 if (uMsg == WM_MENUSELECT) { \
850 SetMsgHandled(TRUE); \
851 func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \
853 if (IsMsgHandled()) \
857 // LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu menu)
858 #define CR_MSG_WM_MENUCHAR(func) \
859 if (uMsg == WM_MENUCHAR) { \
860 SetMsgHandled(TRUE); \
862 func((TCHAR)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \
863 if (IsMsgHandled()) \
867 // LRESULT OnNotify(int idCtrl, LPNMHDR pnmh)
868 #define CR_MSG_WM_NOTIFY(func) \
869 if (uMsg == WM_NOTIFY) { \
870 SetMsgHandled(TRUE); \
871 lResult = func((int)wParam, (LPNMHDR)lParam); \
872 if (IsMsgHandled()) \
876 // void OnEnterIdle(UINT nWhy, CWindow wndWho)
877 #define CR_MSG_WM_ENTERIDLE(func) \
878 if (uMsg == WM_ENTERIDLE) { \
879 SetMsgHandled(TRUE); \
880 func((UINT)wParam, (HWND)lParam); \
882 if (IsMsgHandled()) \
886 // void OnMouseMove(UINT nFlags, CPoint point)
887 #define CR_MSG_WM_MOUSEMOVE(func) \
888 if (uMsg == WM_MOUSEMOVE) { \
889 SetMsgHandled(TRUE); \
891 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
893 if (IsMsgHandled()) \
897 // BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
898 #define CR_MSG_WM_MOUSEWHEEL(func) \
899 if (uMsg == WM_MOUSEWHEEL) { \
900 SetMsgHandled(TRUE); \
901 lResult = (LRESULT)func( \
902 (UINT)LOWORD(wParam), \
903 (short)HIWORD(wParam), \
904 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
905 if (IsMsgHandled()) \
909 // void OnLButtonDown(UINT nFlags, CPoint point)
910 #define CR_MSG_WM_LBUTTONDOWN(func) \
911 if (uMsg == WM_LBUTTONDOWN) { \
912 SetMsgHandled(TRUE); \
914 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
916 if (IsMsgHandled()) \
920 // void OnLButtonUp(UINT nFlags, CPoint point)
921 #define CR_MSG_WM_LBUTTONUP(func) \
922 if (uMsg == WM_LBUTTONUP) { \
923 SetMsgHandled(TRUE); \
925 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
927 if (IsMsgHandled()) \
931 // void OnLButtonDblClk(UINT nFlags, CPoint point)
932 #define CR_MSG_WM_LBUTTONDBLCLK(func) \
933 if (uMsg == WM_LBUTTONDBLCLK) { \
934 SetMsgHandled(TRUE); \
936 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
938 if (IsMsgHandled()) \
942 // void OnRButtonDown(UINT nFlags, CPoint point)
943 #define CR_MSG_WM_RBUTTONDOWN(func) \
944 if (uMsg == WM_RBUTTONDOWN) { \
945 SetMsgHandled(TRUE); \
947 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
949 if (IsMsgHandled()) \
953 // void OnRButtonUp(UINT nFlags, CPoint point)
954 #define CR_MSG_WM_RBUTTONUP(func) \
955 if (uMsg == WM_RBUTTONUP) { \
956 SetMsgHandled(TRUE); \
958 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
960 if (IsMsgHandled()) \
964 // void OnRButtonDblClk(UINT nFlags, CPoint point)
965 #define CR_MSG_WM_RBUTTONDBLCLK(func) \
966 if (uMsg == WM_RBUTTONDBLCLK) { \
967 SetMsgHandled(TRUE); \
969 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
971 if (IsMsgHandled()) \
975 // void OnMButtonDown(UINT nFlags, CPoint point)
976 #define CR_MSG_WM_MBUTTONDOWN(func) \
977 if (uMsg == WM_MBUTTONDOWN) { \
978 SetMsgHandled(TRUE); \
980 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
982 if (IsMsgHandled()) \
986 // void OnMButtonUp(UINT nFlags, CPoint point)
987 #define CR_MSG_WM_MBUTTONUP(func) \
988 if (uMsg == WM_MBUTTONUP) { \
989 SetMsgHandled(TRUE); \
991 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
993 if (IsMsgHandled()) \
997 // void OnMButtonDblClk(UINT nFlags, CPoint point)
998 #define CR_MSG_WM_MBUTTONDBLCLK(func) \
999 if (uMsg == WM_MBUTTONDBLCLK) { \
1000 SetMsgHandled(TRUE); \
1001 func((UINT)wParam, \
1002 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
1004 if (IsMsgHandled()) \
1008 // void OnParentNotify(UINT message, UINT nChildID, LPARAM lParam)
1009 #define CR_MSG_WM_PARENTNOTIFY(func) \
1010 if (uMsg == WM_PARENTNOTIFY) { \
1011 SetMsgHandled(TRUE); \
1012 func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \
1014 if (IsMsgHandled()) \
1018 // void OnMDIActivate(CWindow wndActivate, CWindow wndDeactivate)
1019 #define CR_MSG_WM_MDIACTIVATE(func) \
1020 if (uMsg == WM_MDIACTIVATE) { \
1021 SetMsgHandled(TRUE); \
1022 func((HWND)wParam, (HWND)lParam); \
1024 if (IsMsgHandled()) \
1028 // void OnRenderFormat(UINT nFormat)
1029 #define CR_MSG_WM_RENDERFORMAT(func) \
1030 if (uMsg == WM_RENDERFORMAT) { \
1031 SetMsgHandled(TRUE); \
1032 func((UINT)wParam); \
1034 if (IsMsgHandled()) \
1038 // void OnRenderAllFormats()
1039 #define CR_MSG_WM_RENDERALLFORMATS(func) \
1040 if (uMsg == WM_RENDERALLFORMATS) { \
1041 SetMsgHandled(TRUE); \
1044 if (IsMsgHandled()) \
1048 // void OnDestroyClipboard()
1049 #define CR_MSG_WM_DESTROYCLIPBOARD(func) \
1050 if (uMsg == WM_DESTROYCLIPBOARD) { \
1051 SetMsgHandled(TRUE); \
1054 if (IsMsgHandled()) \
1058 // void OnDrawClipboard()
1059 #define CR_MSG_WM_DRAWCLIPBOARD(func) \
1060 if (uMsg == WM_DRAWCLIPBOARD) { \
1061 SetMsgHandled(TRUE); \
1064 if (IsMsgHandled()) \
1068 // void OnPaintClipboard(CWindow wndViewer, const LPPAINTSTRUCT lpPaintStruct)
1069 #define CR_MSG_WM_PAINTCLIPBOARD(func) \
1070 if (uMsg == WM_PAINTCLIPBOARD) { \
1071 SetMsgHandled(TRUE); \
1072 func((HWND)wParam, (const LPPAINTSTRUCT)::GlobalLock((HGLOBAL)lParam)); \
1073 ::GlobalUnlock((HGLOBAL)lParam); \
1075 if (IsMsgHandled()) \
1079 // void OnVScrollClipboard(CWindow wndViewer, UINT nSBCode, UINT nPos)
1080 #define CR_MSG_WM_VSCROLLCLIPBOARD(func) \
1081 if (uMsg == WM_VSCROLLCLIPBOARD) { \
1082 SetMsgHandled(TRUE); \
1083 func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
1085 if (IsMsgHandled()) \
1089 // void OnContextMenu(CWindow wnd, CPoint point)
1090 #define CR_MSG_WM_CONTEXTMENU(func) \
1091 if (uMsg == WM_CONTEXTMENU) { \
1092 SetMsgHandled(TRUE); \
1093 func((HWND)wParam, \
1094 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
1096 if (IsMsgHandled()) \
1100 // void OnSizeClipboard(CWindow wndViewer, const LPRECT lpRect)
1101 #define CR_MSG_WM_SIZECLIPBOARD(func) \
1102 if (uMsg == WM_SIZECLIPBOARD) { \
1103 SetMsgHandled(TRUE); \
1104 func((HWND)wParam, (const LPRECT)::GlobalLock((HGLOBAL)lParam)); \
1105 ::GlobalUnlock((HGLOBAL)lParam); \
1107 if (IsMsgHandled()) \
1111 // void OnAskCbFormatName(UINT nMaxCount, LPTSTR lpszString)
1112 #define CR_MSG_WM_ASKCBFORMATNAME(func) \
1113 if (uMsg == WM_ASKCBFORMATNAME) { \
1114 SetMsgHandled(TRUE); \
1115 func((DWORD)wParam, (LPTSTR)lParam); \
1117 if (IsMsgHandled()) \
1121 // void OnChangeCbChain(CWindow wndRemove, CWindow wndAfter)
1122 #define CR_MSG_WM_CHANGECBCHAIN(func) \
1123 if (uMsg == WM_CHANGECBCHAIN) { \
1124 SetMsgHandled(TRUE); \
1125 func((HWND)wParam, (HWND)lParam); \
1127 if (IsMsgHandled()) \
1131 // void OnHScrollClipboard(CWindow wndViewer, UINT nSBCode, UINT nPos)
1132 #define CR_MSG_WM_HSCROLLCLIPBOARD(func) \
1133 if (uMsg == WM_HSCROLLCLIPBOARD) { \
1134 SetMsgHandled(TRUE); \
1135 func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
1137 if (IsMsgHandled()) \
1141 // BOOL OnQueryNewPalette()
1142 #define CR_MSG_WM_QUERYNEWPALETTE(func) \
1143 if (uMsg == WM_QUERYNEWPALETTE) { \
1144 SetMsgHandled(TRUE); \
1145 lResult = (LRESULT)func(); \
1146 if (IsMsgHandled()) \
1150 // void OnPaletteChanged(CWindow wndFocus)
1151 #define CR_MSG_WM_PALETTECHANGED(func) \
1152 if (uMsg == WM_PALETTECHANGED) { \
1153 SetMsgHandled(TRUE); \
1154 func((HWND)wParam); \
1156 if (IsMsgHandled()) \
1160 // void OnPaletteIsChanging(CWindow wndPalChg)
1161 #define CR_MSG_WM_PALETTEISCHANGING(func) \
1162 if (uMsg == WM_PALETTEISCHANGING) { \
1163 SetMsgHandled(TRUE); \
1164 func((HWND)wParam); \
1166 if (IsMsgHandled()) \
1170 // void OnDropFiles(HDROP hDropInfo)
1171 #define CR_MSG_WM_DROPFILES(func) \
1172 if (uMsg == WM_DROPFILES) { \
1173 SetMsgHandled(TRUE); \
1174 func((HDROP)wParam); \
1176 if (IsMsgHandled()) \
1180 // void OnWindowPosChanging(LPWINDOWPOS lpWndPos)
1181 #define CR_MSG_WM_WINDOWPOSCHANGING(func) \
1182 if (uMsg == WM_WINDOWPOSCHANGING) { \
1183 SetMsgHandled(TRUE); \
1184 func((LPWINDOWPOS)lParam); \
1186 if (IsMsgHandled()) \
1190 // void OnWindowPosChanged(LPWINDOWPOS lpWndPos)
1191 #define CR_MSG_WM_WINDOWPOSCHANGED(func) \
1192 if (uMsg == WM_WINDOWPOSCHANGED) { \
1193 SetMsgHandled(TRUE); \
1194 func((LPWINDOWPOS)lParam); \
1196 if (IsMsgHandled()) \
1200 // void OnExitMenuLoop(BOOL fIsTrackPopupMenu)
1201 #define CR_MSG_WM_EXITMENULOOP(func) \
1202 if (uMsg == WM_EXITMENULOOP) { \
1203 SetMsgHandled(TRUE); \
1204 func((BOOL)wParam); \
1206 if (IsMsgHandled()) \
1210 // void OnEnterMenuLoop(BOOL fIsTrackPopupMenu)
1211 #define CR_MSG_WM_ENTERMENULOOP(func) \
1212 if (uMsg == WM_ENTERMENULOOP) { \
1213 SetMsgHandled(TRUE); \
1214 func((BOOL)wParam); \
1216 if (IsMsgHandled()) \
1220 // void OnStyleChanged(int nStyleType, LPSTYLESTRUCT lpStyleStruct)
1221 #define CR_MSG_WM_STYLECHANGED(func) \
1222 if (uMsg == WM_STYLECHANGED) { \
1223 SetMsgHandled(TRUE); \
1224 func((UINT)wParam, (LPSTYLESTRUCT)lParam); \
1226 if (IsMsgHandled()) \
1230 // void OnStyleChanging(int nStyleType, LPSTYLESTRUCT lpStyleStruct)
1231 #define CR_MSG_WM_STYLECHANGING(func) \
1232 if (uMsg == WM_STYLECHANGING) { \
1233 SetMsgHandled(TRUE); \
1234 func((UINT)wParam, (LPSTYLESTRUCT)lParam); \
1236 if (IsMsgHandled()) \
1240 // void OnSizing(UINT fwSide, LPRECT pRect)
1241 #define CR_MSG_WM_SIZING(func) \
1242 if (uMsg == WM_SIZING) { \
1243 SetMsgHandled(TRUE); \
1244 func((UINT)wParam, (LPRECT)lParam); \
1246 if (IsMsgHandled()) \
1250 // void OnMoving(UINT fwSide, LPRECT pRect)
1251 #define CR_MSG_WM_MOVING(func) \
1252 if (uMsg == WM_MOVING) { \
1253 SetMsgHandled(TRUE); \
1254 func((UINT)wParam, (LPRECT)lParam); \
1256 if (IsMsgHandled()) \
1260 // void OnCaptureChanged(CWindow wnd)
1261 #define CR_MSG_WM_CAPTURECHANGED(func) \
1262 if (uMsg == WM_CAPTURECHANGED) { \
1263 SetMsgHandled(TRUE); \
1264 func((HWND)lParam); \
1266 if (IsMsgHandled()) \
1270 // BOOL OnDeviceChange(UINT nEventType, DWORD dwData)
1271 #define CR_MSG_WM_DEVICECHANGE(func) \
1272 if (uMsg == WM_DEVICECHANGE) { \
1273 SetMsgHandled(TRUE); \
1274 lResult = (LRESULT)func((UINT)wParam, (DWORD)lParam); \
1275 if (IsMsgHandled()) \
1279 // void OnCommand(UINT uNotifyCode, int nID, CWindow wndCtl)
1280 #define CR_MSG_WM_COMMAND(func) \
1281 if (uMsg == WM_COMMAND) { \
1282 SetMsgHandled(TRUE); \
1283 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
1285 if (IsMsgHandled()) \
1289 // void OnDisplayChange(UINT uBitsPerPixel, gfx::Size sizeScreen)
1290 #define CR_MSG_WM_DISPLAYCHANGE(func) \
1291 if (uMsg == WM_DISPLAYCHANGE) { \
1292 SetMsgHandled(TRUE); \
1293 func((UINT)wParam, \
1294 gfx::Size(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
1296 if (IsMsgHandled()) \
1300 // void OnEnterSizeMove()
1301 #define CR_MSG_WM_ENTERSIZEMOVE(func) \
1302 if (uMsg == WM_ENTERSIZEMOVE) { \
1303 SetMsgHandled(TRUE); \
1306 if (IsMsgHandled()) \
1310 // void OnExitSizeMove()
1311 #define CR_MSG_WM_EXITSIZEMOVE(func) \
1312 if (uMsg == WM_EXITSIZEMOVE) { \
1313 SetMsgHandled(TRUE); \
1316 if (IsMsgHandled()) \
1320 // HFONT OnGetFont()
1321 #define CR_MSG_WM_GETFONT(func) \
1322 if (uMsg == WM_GETFONT) { \
1323 SetMsgHandled(TRUE); \
1324 lResult = (LRESULT)func(); \
1325 if (IsMsgHandled()) \
1329 // LRESULT OnGetHotKey()
1330 #define CR_MSG_WM_GETHOTKEY(func) \
1331 if (uMsg == WM_GETHOTKEY) { \
1332 SetMsgHandled(TRUE); \
1334 if (IsMsgHandled()) \
1338 // HICON OnGetIcon()
1339 #define CR_MSG_WM_GETICON(func) \
1340 if (uMsg == WM_GETICON) { \
1341 SetMsgHandled(TRUE); \
1342 lResult = (LRESULT)func((UINT)wParam); \
1343 if (IsMsgHandled()) \
1347 // int OnGetText(int cchTextMax, LPTSTR lpszText)
1348 #define CR_MSG_WM_GETTEXT(func) \
1349 if (uMsg == WM_GETTEXT) { \
1350 SetMsgHandled(TRUE); \
1351 lResult = (LRESULT)func((int)wParam, (LPTSTR)lParam); \
1352 if (IsMsgHandled()) \
1356 // int OnGetTextLength()
1357 #define CR_MSG_WM_GETTEXTLENGTH(func) \
1358 if (uMsg == WM_GETTEXTLENGTH) { \
1359 SetMsgHandled(TRUE); \
1360 lResult = (LRESULT)func(); \
1361 if (IsMsgHandled()) \
1365 // void OnHelp(LPHELPINFO lpHelpInfo)
1366 #define CR_MSG_WM_HELP(func) \
1367 if (uMsg == WM_HELP) { \
1368 SetMsgHandled(TRUE); \
1369 func((LPHELPINFO)lParam); \
1371 if (IsMsgHandled()) \
1375 // void OnHotKey(int nHotKeyID, UINT uModifiers, UINT uVirtKey)
1376 #define CR_MSG_WM_HOTKEY(func) \
1377 if (uMsg == WM_HOTKEY) { \
1378 SetMsgHandled(TRUE); \
1379 func((int)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
1381 if (IsMsgHandled()) \
1385 // void OnInputLangChange(DWORD dwCharSet, HKL hKbdLayout)
1386 #define CR_MSG_WM_INPUTLANGCHANGE(func) \
1387 if (uMsg == WM_INPUTLANGCHANGE) { \
1388 SetMsgHandled(TRUE); \
1389 func((DWORD)wParam, (HKL)lParam); \
1391 if (IsMsgHandled()) \
1395 // void OnInputLangChangeRequest(BOOL bSysCharSet, HKL hKbdLayout)
1396 #define CR_MSG_WM_INPUTLANGCHANGEREQUEST(func) \
1397 if (uMsg == WM_INPUTLANGCHANGEREQUEST) { \
1398 SetMsgHandled(TRUE); \
1399 func((BOOL)wParam, (HKL)lParam); \
1401 if (IsMsgHandled()) \
1405 // void OnNextDlgCtl(BOOL bHandle, WPARAM wCtlFocus)
1406 #define CR_MSG_WM_NEXTDLGCTL(func) \
1407 if (uMsg == WM_NEXTDLGCTL) { \
1408 SetMsgHandled(TRUE); \
1409 func((BOOL)LOWORD(lParam), wParam); \
1411 if (IsMsgHandled()) \
1415 // void OnNextMenu(int nVirtKey, LPMDINEXTMENU lpMdiNextMenu)
1416 #define CR_MSG_WM_NEXTMENU(func) \
1417 if (uMsg == WM_NEXTMENU) { \
1418 SetMsgHandled(TRUE); \
1419 func((int)wParam, (LPMDINEXTMENU)lParam); \
1421 if (IsMsgHandled()) \
1425 // int OnNotifyFormat(CWindow wndFrom, int nCommand)
1426 #define CR_MSG_WM_NOTIFYFORMAT(func) \
1427 if (uMsg == WM_NOTIFYFORMAT) { \
1428 SetMsgHandled(TRUE); \
1429 lResult = (LRESULT)func((HWND)wParam, (int)lParam); \
1430 if (IsMsgHandled()) \
1434 // BOOL OnPowerBroadcast(DWORD dwPowerEvent, DWORD dwData)
1435 #define CR_MSG_WM_POWERBROADCAST(func) \
1436 if (uMsg == WM_POWERBROADCAST) { \
1437 SetMsgHandled(TRUE); \
1438 lResult = (LRESULT)func((DWORD)wParam, (DWORD)lParam); \
1439 if (IsMsgHandled()) \
1443 // void OnPrint(CDCHandle dc, UINT uFlags)
1444 #define CR_MSG_WM_PRINT(func) \
1445 if (uMsg == WM_PRINT) { \
1446 SetMsgHandled(TRUE); \
1447 func((HDC)wParam, (UINT)lParam); \
1449 if (IsMsgHandled()) \
1453 // void OnPrintClient(CDCHandle dc, UINT uFlags)
1454 #define CR_MSG_WM_PRINTCLIENT(func) \
1455 if (uMsg == WM_PRINTCLIENT) { \
1456 SetMsgHandled(TRUE); \
1457 func((HDC)wParam, (UINT)lParam); \
1459 if (IsMsgHandled()) \
1463 // void OnRasDialEvent(RASCONNSTATE rasconnstate, DWORD dwError)
1464 #define CR_MSG_WM_RASDIALEVENT(func) \
1465 if (uMsg == WM_RASDIALEVENT) { \
1466 SetMsgHandled(TRUE); \
1467 func((RASCONNSTATE)wParam, (DWORD)lParam); \
1469 if (IsMsgHandled()) \
1473 // void OnSetFont(CFont font, BOOL bRedraw)
1474 #define CR_MSG_WM_SETFONT(func) \
1475 if (uMsg == WM_SETFONT) { \
1476 SetMsgHandled(TRUE); \
1477 func((HFONT)wParam, (BOOL)LOWORD(lParam)); \
1479 if (IsMsgHandled()) \
1483 // int OnSetHotKey(int nVirtKey, UINT uFlags)
1484 #define CR_MSG_WM_SETHOTKEY(func) \
1485 if (uMsg == WM_SETHOTKEY) { \
1486 SetMsgHandled(TRUE); \
1487 lResult = (LRESULT)func((int)LOBYTE(LOWORD(wParam)), \
1488 (UINT)HIBYTE(LOWORD(wParam))); \
1489 if (IsMsgHandled()) \
1493 // HICON OnSetIcon(UINT uType, HICON hIcon)
1494 #define CR_MSG_WM_SETICON(func) \
1495 if (uMsg == WM_SETICON) { \
1496 SetMsgHandled(TRUE); \
1497 lResult = (LRESULT)func((UINT)wParam, (HICON)lParam); \
1498 if (IsMsgHandled()) \
1502 // void OnSetRedraw(BOOL bRedraw)
1503 #define CR_MSG_WM_SETREDRAW(func) \
1504 if (uMsg == WM_SETREDRAW) { \
1505 SetMsgHandled(TRUE); \
1506 func((BOOL)wParam); \
1508 if (IsMsgHandled()) \
1512 // int OnSetText(LPCTSTR lpstrText)
1513 #define CR_MSG_WM_SETTEXT(func) \
1514 if (uMsg == WM_SETTEXT) { \
1515 SetMsgHandled(TRUE); \
1516 lResult = (LRESULT)func((LPCTSTR)lParam); \
1517 if (IsMsgHandled()) \
1521 // void OnUserChanged()
1522 #define CR_MSG_WM_USERCHANGED(func) \
1523 if (uMsg == WM_USERCHANGED) { \
1524 SetMsgHandled(TRUE); \
1527 if (IsMsgHandled()) \
1531 ///////////////////////////////////////////////////////////////////////////////
1532 // New NT4 & NT5 messages
1534 #if (_WIN32_WINNT >= 0x0400)
1536 // void OnMouseHover(WPARAM wParam, CPoint ptPos)
1537 #define CR_MSG_WM_MOUSEHOVER(func) \
1538 if (uMsg == WM_MOUSEHOVER) { \
1539 SetMsgHandled(TRUE); \
1541 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
1543 if (IsMsgHandled()) \
1547 // void OnMouseLeave()
1548 #define CR_MSG_WM_MOUSELEAVE(func) \
1549 if (uMsg == WM_MOUSELEAVE) { \
1550 SetMsgHandled(TRUE); \
1553 if (IsMsgHandled()) \
1557 #endif /* _WIN32_WINNT >= 0x0400 */
1559 #if (WINVER >= 0x0500)
1561 // void OnMenuRButtonUp(WPARAM wParam, CMenu menu)
1562 #define CR_MSG_WM_MENURBUTTONUP(func) \
1563 if (uMsg == WM_MENURBUTTONUP) { \
1564 SetMsgHandled(TRUE); \
1565 func(wParam, (HMENU)lParam); \
1567 if (IsMsgHandled()) \
1571 // LRESULT OnMenuDrag(WPARAM wParam, CMenu menu)
1572 #define CR_MSG_WM_MENUDRAG(func) \
1573 if (uMsg == WM_MENUDRAG) { \
1574 SetMsgHandled(TRUE); \
1575 lResult = func(wParam, (HMENU)lParam); \
1576 if (IsMsgHandled()) \
1580 // LRESULT OnMenuGetObject(PMENUGETOBJECTINFO info)
1581 #define CR_MSG_WM_MENUGETOBJECT(func) \
1582 if (uMsg == WM_MENUGETOBJECT) { \
1583 SetMsgHandled(TRUE); \
1584 lResult = func((PMENUGETOBJECTINFO)lParam); \
1585 if (IsMsgHandled()) \
1589 // void OnUnInitMenuPopup(UINT nID, CMenu menu)
1590 #define CR_MSG_WM_UNINITMENUPOPUP(func) \
1591 if (uMsg == WM_UNINITMENUPOPUP) { \
1592 SetMsgHandled(TRUE); \
1593 func((UINT)HIWORD(lParam), (HMENU)wParam); \
1595 if (IsMsgHandled()) \
1599 // void OnMenuCommand(WPARAM nIndex, CMenu menu)
1600 #define CR_MSG_WM_MENUCOMMAND(func) \
1601 if (uMsg == WM_MENUCOMMAND) { \
1602 SetMsgHandled(TRUE); \
1603 func(wParam, (HMENU)lParam); \
1605 if (IsMsgHandled()) \
1609 #endif /* WINVER >= 0x0500 */
1611 #if (_WIN32_WINNT >= 0x0500)
1613 // BOOL OnAppCommand(CWindow wndFocus, short cmd, WORD uDevice, int dwKeys)
1614 #define CR_MSG_WM_APPCOMMAND(func) \
1615 if (uMsg == WM_APPCOMMAND) { \
1616 SetMsgHandled(TRUE); \
1617 lResult = (LRESULT)func((HWND)wParam, \
1618 GET_APPCOMMAND_LPARAM(lParam), \
1619 GET_DEVICE_LPARAM(lParam), \
1620 GET_KEYSTATE_LPARAM(lParam)); \
1621 if (IsMsgHandled()) \
1625 // void OnNCXButtonDown(int fwButton, short nHittest, CPoint ptPos)
1626 #define CR_MSG_WM_NCXBUTTONDOWN(func) \
1627 if (uMsg == WM_NCXBUTTONDOWN) { \
1628 SetMsgHandled(TRUE); \
1629 func(GET_XBUTTON_WPARAM(wParam), \
1630 GET_NCHITTEST_WPARAM(wParam), \
1631 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
1633 if (IsMsgHandled()) \
1637 // void OnNCXButtonUp(int fwButton, short nHittest, CPoint ptPos)
1638 #define CR_MSG_WM_NCXBUTTONUP(func) \
1639 if (uMsg == WM_NCXBUTTONUP) { \
1640 SetMsgHandled(TRUE); \
1641 func(GET_XBUTTON_WPARAM(wParam), \
1642 GET_NCHITTEST_WPARAM(wParam), \
1643 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
1645 if (IsMsgHandled()) \
1649 // void OnNCXButtonDblClk(int fwButton, short nHittest, CPoint ptPos)
1650 #define CR_MSG_WM_NCXBUTTONDBLCLK(func) \
1651 if (uMsg == WM_NCXBUTTONDBLCLK) { \
1652 SetMsgHandled(TRUE); \
1653 func(GET_XBUTTON_WPARAM(wParam), \
1654 GET_NCHITTEST_WPARAM(wParam), \
1655 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
1657 if (IsMsgHandled()) \
1661 // void OnXButtonDown(int fwButton, int dwKeys, CPoint ptPos)
1662 #define CR_MSG_WM_XBUTTONDOWN(func) \
1663 if (uMsg == WM_XBUTTONDOWN) { \
1664 SetMsgHandled(TRUE); \
1665 func(GET_XBUTTON_WPARAM(wParam), \
1666 GET_KEYSTATE_WPARAM(wParam), \
1667 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
1669 if (IsMsgHandled()) \
1673 // void OnXButtonUp(int fwButton, int dwKeys, CPoint ptPos)
1674 #define CR_MSG_WM_XBUTTONUP(func) \
1675 if (uMsg == WM_XBUTTONUP) { \
1676 SetMsgHandled(TRUE); \
1677 func(GET_XBUTTON_WPARAM(wParam), \
1678 GET_KEYSTATE_WPARAM(wParam), \
1679 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
1681 if (IsMsgHandled()) \
1685 // void OnXButtonDblClk(int fwButton, int dwKeys, CPoint ptPos)
1686 #define CR_MSG_WM_XBUTTONDBLCLK(func) \
1687 if (uMsg == WM_XBUTTONDBLCLK) { \
1688 SetMsgHandled(TRUE); \
1689 func(GET_XBUTTON_WPARAM(wParam), \
1690 GET_KEYSTATE_WPARAM(wParam), \
1691 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
1693 if (IsMsgHandled()) \
1697 // void OnChangeUIState(WORD nAction, WORD nState)
1698 #define CR_MSG_WM_CHANGEUISTATE(func) \
1699 if (uMsg == WM_CHANGEUISTATE) { \
1700 SetMsgHandled(TRUE); \
1701 func(LOWORD(wParam), HIWORD(wParam)); \
1703 if (IsMsgHandled()) \
1707 // void OnUpdateUIState(WORD nAction, WORD nState)
1708 #define CR_MSG_WM_UPDATEUISTATE(func) \
1709 if (uMsg == WM_UPDATEUISTATE) { \
1710 SetMsgHandled(TRUE); \
1711 func(LOWORD(wParam), HIWORD(wParam)); \
1713 if (IsMsgHandled()) \
1717 // LRESULT OnQueryUIState()
1718 #define CR_MSG_WM_QUERYUISTATE(func) \
1719 if (uMsg == WM_QUERYUISTATE) { \
1720 SetMsgHandled(TRUE); \
1722 if (IsMsgHandled()) \
1726 #endif // (_WIN32_WINNT >= 0x0500)
1728 #if (_WIN32_WINNT >= 0x0501)
1730 // void OnInput(WPARAM RawInputCode, HRAWINPUT hRawInput)
1731 #define CR_MSG_WM_INPUT(func) \
1732 if (uMsg == WM_INPUT) { \
1733 SetMsgHandled(TRUE); \
1734 func(GET_RAWINPUT_CODE_WPARAM(wParam), (HRAWINPUT)lParam); \
1736 if (IsMsgHandled()) \
1740 // void OnUniChar(TCHAR nChar, UINT nRepCnt, UINT nFlags)
1741 #define CR_MSG_WM_UNICHAR(func) \
1742 if (uMsg == WM_UNICHAR) { \
1743 SetMsgHandled(TRUE); \
1744 func((TCHAR)wParam, \
1745 (UINT)lParam & 0xFFFF, \
1746 (UINT)((lParam & 0xFFFF0000) >> 16)); \
1747 if (IsMsgHandled()) { \
1748 lResult = (wParam == UNICODE_NOCHAR) ? TRUE : FALSE; \
1753 // void OnWTSSessionChange(WPARAM nStatusCode, PWTSSESSION_NOTIFICATION
1755 #define CR_MSG_WM_WTSSESSION_CHANGE(func) \
1756 if (uMsg == WM_WTSSESSION_CHANGE) { \
1757 SetMsgHandled(TRUE); \
1758 func(wParam, (PWTSSESSION_NOTIFICATION)lParam); \
1760 if (IsMsgHandled()) \
1765 #define CR_MSG_WM_THEMECHANGED(func) \
1766 if (uMsg == WM_THEMECHANGED) { \
1767 SetMsgHandled(TRUE); \
1770 if (IsMsgHandled()) \
1774 #endif /* _WIN32_WINNT >= 0x0501 */
1776 ///////////////////////////////////////////////////////////////////////////////
1777 // ATL defined messages
1779 // BOOL OnForwardMsg(LPMSG Msg, DWORD nUserData)
1780 #define CR_MSG_WM_FORWARDMSG(func) \
1781 if (uMsg == WM_FORWARDMSG) { \
1782 SetMsgHandled(TRUE); \
1783 lResult = (LRESULT)func((LPMSG)lParam, (DWORD)wParam); \
1784 if (IsMsgHandled()) \
1788 ///////////////////////////////////////////////////////////////////////////////
1789 // Dialog specific messages
1791 // LRESULT OnDMGetDefID()
1792 #define MSG_DM_GETDEFID(func) \
1793 if (uMsg == DM_GETDEFID) { \
1794 SetMsgHandled(TRUE); \
1796 if (IsMsgHandled()) \
1800 // void OnDMSetDefID(UINT DefID)
1801 #define MSG_DM_SETDEFID(func) \
1802 if (uMsg == DM_SETDEFID) { \
1803 SetMsgHandled(TRUE); \
1804 func((UINT)wParam); \
1806 if (IsMsgHandled()) \
1810 // void OnDMReposition()
1811 #define MSG_DM_REPOSITION(func) \
1812 if (uMsg == DM_REPOSITION) { \
1813 SetMsgHandled(TRUE); \
1816 if (IsMsgHandled()) \
1820 ///////////////////////////////////////////////////////////////////////////////
1821 // Reflected messages
1823 // void OnReflectedCommand(UINT uNotifyCode, int nID, CWindow wndCtl)
1824 #define MSG_OCM_COMMAND(func) \
1825 if (uMsg == OCM_COMMAND) { \
1826 SetMsgHandled(TRUE); \
1827 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
1829 if (IsMsgHandled()) \
1833 // LRESULT OnReflectedNotify(int idCtrl, LPNMHDR pnmh)
1834 #define MSG_OCM_NOTIFY(func) \
1835 if (uMsg == OCM_NOTIFY) { \
1836 SetMsgHandled(TRUE); \
1837 lResult = func((int)wParam, (LPNMHDR)lParam); \
1838 if (IsMsgHandled()) \
1842 // void OnReflectedParentNotify(UINT message, UINT nChildID, LPARAM lParam)
1843 #define MSG_OCM_PARENTNOTIFY(func) \
1844 if (uMsg == OCM_PARENTNOTIFY) { \
1845 SetMsgHandled(TRUE); \
1846 func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \
1848 if (IsMsgHandled()) \
1852 // void OnReflectedDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
1853 #define MSG_OCM_DRAWITEM(func) \
1854 if (uMsg == OCM_DRAWITEM) { \
1855 SetMsgHandled(TRUE); \
1856 func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \
1858 if (IsMsgHandled()) \
1862 // void OnReflectedMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT
1863 // lpMeasureItemStruct)
1864 #define MSG_OCM_MEASUREITEM(func) \
1865 if (uMsg == OCM_MEASUREITEM) { \
1866 SetMsgHandled(TRUE); \
1867 func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \
1869 if (IsMsgHandled()) \
1873 // int OnReflectedCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT
1874 // lpCompareItemStruct)
1875 #define MSG_OCM_COMPAREITEM(func) \
1876 if (uMsg == OCM_COMPAREITEM) { \
1877 SetMsgHandled(TRUE); \
1878 lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \
1879 if (IsMsgHandled()) \
1883 // void OnReflectedDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct)
1884 #define MSG_OCM_DELETEITEM(func) \
1885 if (uMsg == OCM_DELETEITEM) { \
1886 SetMsgHandled(TRUE); \
1887 func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \
1889 if (IsMsgHandled()) \
1893 // int OnReflectedVKeyToItem(UINT nKey, UINT nIndex, CListBox listBox)
1894 #define MSG_OCM_VKEYTOITEM(func) \
1895 if (uMsg == OCM_VKEYTOITEM) { \
1896 SetMsgHandled(TRUE); \
1897 lResult = (LRESULT)func( \
1898 (UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
1899 if (IsMsgHandled()) \
1903 // int OnReflectedCharToItem(UINT nChar, UINT nIndex, CListBox listBox)
1904 #define MSG_OCM_CHARTOITEM(func) \
1905 if (uMsg == OCM_CHARTOITEM) { \
1906 SetMsgHandled(TRUE); \
1907 lResult = (LRESULT)func( \
1908 (UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
1909 if (IsMsgHandled()) \
1913 // void OnReflectedHScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
1914 #define MSG_OCM_HSCROLL(func) \
1915 if (uMsg == OCM_HSCROLL) { \
1916 SetMsgHandled(TRUE); \
1917 func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
1919 if (IsMsgHandled()) \
1923 // void OnReflectedVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
1924 #define MSG_OCM_VSCROLL(func) \
1925 if (uMsg == OCM_VSCROLL) { \
1926 SetMsgHandled(TRUE); \
1927 func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
1929 if (IsMsgHandled()) \
1933 // HBRUSH OnReflectedCtlColorEdit(CDCHandle dc, CEdit edit)
1934 #define MSG_OCM_CTLCOLOREDIT(func) \
1935 if (uMsg == OCM_CTLCOLOREDIT) { \
1936 SetMsgHandled(TRUE); \
1937 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
1938 if (IsMsgHandled()) \
1942 // HBRUSH OnReflectedCtlColorListBox(CDCHandle dc, CListBox listBox)
1943 #define MSG_OCM_CTLCOLORLISTBOX(func) \
1944 if (uMsg == OCM_CTLCOLORLISTBOX) { \
1945 SetMsgHandled(TRUE); \
1946 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
1947 if (IsMsgHandled()) \
1951 // HBRUSH OnReflectedCtlColorBtn(CDCHandle dc, CButton button)
1952 #define MSG_OCM_CTLCOLORBTN(func) \
1953 if (uMsg == OCM_CTLCOLORBTN) { \
1954 SetMsgHandled(TRUE); \
1955 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
1956 if (IsMsgHandled()) \
1960 // HBRUSH OnReflectedCtlColorDlg(CDCHandle dc, CWindow wnd)
1961 #define MSG_OCM_CTLCOLORDLG(func) \
1962 if (uMsg == OCM_CTLCOLORDLG) { \
1963 SetMsgHandled(TRUE); \
1964 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
1965 if (IsMsgHandled()) \
1969 // HBRUSH OnReflectedCtlColorScrollBar(CDCHandle dc, CScrollBar scrollBar)
1970 #define MSG_OCM_CTLCOLORSCROLLBAR(func) \
1971 if (uMsg == OCM_CTLCOLORSCROLLBAR) { \
1972 SetMsgHandled(TRUE); \
1973 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
1974 if (IsMsgHandled()) \
1978 // HBRUSH OnReflectedCtlColorStatic(CDCHandle dc, CStatic wndStatic)
1979 #define MSG_OCM_CTLCOLORSTATIC(func) \
1980 if (uMsg == OCM_CTLCOLORSTATIC) { \
1981 SetMsgHandled(TRUE); \
1982 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
1983 if (IsMsgHandled()) \
1987 ///////////////////////////////////////////////////////////////////////////////
1988 // Edit specific messages
1991 #define CR_MSG_WM_CLEAR(func) \
1992 if (uMsg == WM_CLEAR) { \
1993 SetMsgHandled(TRUE); \
1996 if (IsMsgHandled()) \
2001 #define CR_MSG_WM_COPY(func) \
2002 if (uMsg == WM_COPY) { \
2003 SetMsgHandled(TRUE); \
2006 if (IsMsgHandled()) \
2011 #define CR_MSG_WM_CUT(func) \
2012 if (uMsg == WM_CUT) { \
2013 SetMsgHandled(TRUE); \
2016 if (IsMsgHandled()) \
2021 #define CR_MSG_WM_PASTE(func) \
2022 if (uMsg == WM_PASTE) { \
2023 SetMsgHandled(TRUE); \
2026 if (IsMsgHandled()) \
2031 #define CR_MSG_WM_UNDO(func) \
2032 if (uMsg == WM_UNDO) { \
2033 SetMsgHandled(TRUE); \
2036 if (IsMsgHandled()) \
2040 ///////////////////////////////////////////////////////////////////////////////
2041 // Generic message handlers
2043 // LRESULT OnMessageHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam)
2044 #define CR_MESSAGE_HANDLER_EX(msg, func) \
2045 if (uMsg == msg) { \
2046 SetMsgHandled(TRUE); \
2047 lResult = func(uMsg, wParam, lParam); \
2048 if (IsMsgHandled()) \
2052 // LRESULT OnMessageRangeHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam)
2053 #define CR_MESSAGE_RANGE_HANDLER_EX(msgFirst, msgLast, func) \
2054 if (uMsg >= msgFirst && uMsg <= msgLast) { \
2055 SetMsgHandled(TRUE); \
2056 lResult = func(uMsg, wParam, lParam); \
2057 if (IsMsgHandled()) \
2061 ///////////////////////////////////////////////////////////////////////////////
2062 // Commands and notifications
2064 // void OnCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2065 #define CR_COMMAND_HANDLER_EX(id, code, func) \
2066 if (uMsg == WM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) { \
2067 SetMsgHandled(TRUE); \
2068 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2070 if (IsMsgHandled()) \
2074 // void OnCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2075 #define CR_COMMAND_ID_HANDLER_EX(id, func) \
2076 if (uMsg == WM_COMMAND && id == LOWORD(wParam)) { \
2077 SetMsgHandled(TRUE); \
2078 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2080 if (IsMsgHandled()) \
2084 // void OnCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2085 #define CR_COMMAND_CODE_HANDLER_EX(code, func) \
2086 if (uMsg == WM_COMMAND && code == HIWORD(wParam)) { \
2087 SetMsgHandled(TRUE); \
2088 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2090 if (IsMsgHandled()) \
2094 // LRESULT OnNotifyHandlerEX(LPNMHDR pnmh)
2095 #define CR_NOTIFY_HANDLER_EX(id, cd, func) \
2096 if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && \
2097 id == ((LPNMHDR)lParam)->idFrom) { \
2098 SetMsgHandled(TRUE); \
2099 lResult = func((LPNMHDR)lParam); \
2100 if (IsMsgHandled()) \
2104 // LRESULT OnNotifyIDHandlerEX(LPNMHDR pnmh)
2105 #define CR_NOTIFY_ID_HANDLER_EX(id, func) \
2106 if (uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) { \
2107 SetMsgHandled(TRUE); \
2108 lResult = func((LPNMHDR)lParam); \
2109 if (IsMsgHandled()) \
2113 // LRESULT OnNotifyCodeHandlerEX(LPNMHDR pnmh)
2114 #define CR_NOTIFY_CODE_HANDLER_EX(cd, func) \
2115 if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) { \
2116 SetMsgHandled(TRUE); \
2117 lResult = func((LPNMHDR)lParam); \
2118 if (IsMsgHandled()) \
2122 // void OnCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2123 #define CR_COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \
2124 if (uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && \
2125 LOWORD(wParam) <= idLast) { \
2126 SetMsgHandled(TRUE); \
2127 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2129 if (IsMsgHandled()) \
2133 // void OnCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2134 #define CR_COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \
2135 if (uMsg == WM_COMMAND && code == HIWORD(wParam) && \
2136 LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) { \
2137 SetMsgHandled(TRUE); \
2138 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2140 if (IsMsgHandled()) \
2144 // LRESULT OnNotifyRangeHandlerEX(LPNMHDR pnmh)
2145 #define CR_NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \
2146 if (uMsg == WM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && \
2147 ((LPNMHDR)lParam)->idFrom <= idLast) { \
2148 SetMsgHandled(TRUE); \
2149 lResult = func((LPNMHDR)lParam); \
2150 if (IsMsgHandled()) \
2154 // LRESULT OnNotifyRangeCodeHandlerEX(LPNMHDR pnmh)
2155 #define CR_NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \
2156 if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && \
2157 ((LPNMHDR)lParam)->idFrom >= idFirst && \
2158 ((LPNMHDR)lParam)->idFrom <= idLast) { \
2159 SetMsgHandled(TRUE); \
2160 lResult = func((LPNMHDR)lParam); \
2161 if (IsMsgHandled()) \
2165 // LRESULT OnReflectedCommandHandlerEX(UINT uNotifyCode, int nID, CWindow
2167 #define CR_REFLECTED_COMMAND_HANDLER_EX(id, code, func) \
2168 if (uMsg == OCM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) { \
2169 SetMsgHandled(TRUE); \
2170 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2172 if (IsMsgHandled()) \
2176 // LRESULT OnReflectedCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow
2178 #define CR_REFLECTED_COMMAND_ID_HANDLER_EX(id, func) \
2179 if (uMsg == OCM_COMMAND && id == LOWORD(wParam)) { \
2180 SetMsgHandled(TRUE); \
2181 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2183 if (IsMsgHandled()) \
2187 // LRESULT OnReflectedCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow
2189 #define CR_REFLECTED_COMMAND_CODE_HANDLER_EX(code, func) \
2190 if (uMsg == OCM_COMMAND && code == HIWORD(wParam)) { \
2191 SetMsgHandled(TRUE); \
2192 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2194 if (IsMsgHandled()) \
2198 // LRESULT OnReflectedNotifyHandlerEX(LPNMHDR pnmh)
2199 #define CR_REFLECTED_NOTIFY_HANDLER_EX(id, cd, func) \
2200 if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && \
2201 id == ((LPNMHDR)lParam)->idFrom) { \
2202 SetMsgHandled(TRUE); \
2203 lResult = func((LPNMHDR)lParam); \
2204 if (IsMsgHandled()) \
2208 // LRESULT OnReflectedNotifyIDHandlerEX(LPNMHDR pnmh)
2209 #define CR_REFLECTED_NOTIFY_ID_HANDLER_EX(id, func) \
2210 if (uMsg == OCM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) { \
2211 SetMsgHandled(TRUE); \
2212 lResult = func((LPNMHDR)lParam); \
2213 if (IsMsgHandled()) \
2217 // LRESULT OnReflectedNotifyCodeHandlerEX(LPNMHDR pnmh)
2218 #define CR_REFLECTED_NOTIFY_CODE_HANDLER_EX(cd, func) \
2219 if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code) { \
2220 SetMsgHandled(TRUE); \
2221 lResult = func((LPNMHDR)lParam); \
2222 if (IsMsgHandled()) \
2226 // void OnReflectedCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow
2228 #define CR_REFLECTED_COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \
2229 if (uMsg == OCM_COMMAND && LOWORD(wParam) >= idFirst && \
2230 LOWORD(wParam) <= idLast) { \
2231 SetMsgHandled(TRUE); \
2232 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2234 if (IsMsgHandled()) \
2238 // void OnReflectedCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow
2240 #define CR_REFLECTED_COMMAND_RANGE_CODE_HANDLER_EX( \
2241 idFirst, idLast, code, func) \
2242 if (uMsg == OCM_COMMAND && code == HIWORD(wParam) && \
2243 LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) { \
2244 SetMsgHandled(TRUE); \
2245 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2247 if (IsMsgHandled()) \
2251 // LRESULT OnReflectedNotifyRangeHandlerEX(LPNMHDR pnmh)
2252 #define CR_REFLECTED_NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \
2253 if (uMsg == OCM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && \
2254 ((LPNMHDR)lParam)->idFrom <= idLast) { \
2255 SetMsgHandled(TRUE); \
2256 lResult = func((LPNMHDR)lParam); \
2257 if (IsMsgHandled()) \
2261 // LRESULT OnReflectedNotifyRangeCodeHandlerEX(LPNMHDR pnmh)
2262 #define CR_REFLECTED_NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \
2263 if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && \
2264 ((LPNMHDR)lParam)->idFrom >= idFirst && \
2265 ((LPNMHDR)lParam)->idFrom <= idLast) { \
2266 SetMsgHandled(TRUE); \
2267 lResult = func((LPNMHDR)lParam); \
2268 if (IsMsgHandled()) \
2272 #define CR_DEFLATE_RECT(rect, by) \
2274 (rect)->left += (by)->left; \
2275 (rect)->top += (by)->top; \
2276 (rect)->right -= (by)->right; \
2277 (rect)->bottom -= (by)->bottom; \
2280 #define CR_POINT_INITIALIZER_FROM_LPARAM(lparam) \
2281 { LOWORD(lparam), HIWORD(lparam) }
2283 #endif // UI_GFX_WIN_MSG_UTIL_H_