Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ui / gfx / win / msg_util.h
blob0eb5123fad85b98c046af33ecf4e65b50d3bf2c5
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,
15 // CSize, etc.
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
23 // derived classes,
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) \
28 public: \
29 BOOL m_bMsgHandled; \
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, \
34 UINT uMsg, \
35 WPARAM wParam, \
36 LPARAM lParam, \
37 LRESULT& lResult, \
38 DWORD dwMsgMapID = 0) override { \
39 BOOL bOldMsgHandled = m_bMsgHandled; \
40 BOOL bRet = _ProcessWindowMessage( \
41 hWnd, uMsg, wParam, lParam, lResult, dwMsgMapID); \
42 m_bMsgHandled = bOldMsgHandled; \
43 return bRet; \
44 } \
45 BOOL _ProcessWindowMessage(HWND hWnd, \
46 UINT uMsg, \
47 WPARAM wParam, \
48 LPARAM lParam, \
49 LRESULT& lResult, \
50 DWORD dwMsgMapID) { \
51 BOOL bHandled = TRUE; \
52 hWnd; \
53 uMsg; \
54 wParam; \
55 lParam; \
56 lResult; \
57 bHandled; \
58 switch (dwMsgMapID) { \
59 case 0:
61 // Replacement for atlwin.h's END_MSG_MAP for removing ATL usage.
62 #define CR_END_MSG_MAP() \
63 break; \
64 default: \
65 NOTREACHED() << "Invalid message map ID: " << dwMsgMapID; \
66 break; \
67 } \
68 return FALSE; \
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); \
82 if (IsMsgHandled()) \
83 return TRUE; \
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); \
91 if (IsMsgHandled()) \
92 return TRUE; \
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()) \
101 return TRUE; \
104 // void OnDestroy()
105 #define CR_MSG_WM_DESTROY(func) \
106 if (uMsg == WM_DESTROY) { \
107 SetMsgHandled(TRUE); \
108 func(); \
109 lResult = 0; \
110 if (IsMsgHandled()) \
111 return TRUE; \
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))); \
119 lResult = 0; \
120 if (IsMsgHandled()) \
121 return TRUE; \
124 // void OnSize(UINT nType, gfx::Size size)
125 #define CR_MSG_WM_SIZE(func) \
126 if (uMsg == WM_SIZE) { \
127 SetMsgHandled(TRUE); \
128 func((UINT)wParam, \
129 gfx::Size(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
130 lResult = 0; \
131 if (IsMsgHandled()) \
132 return TRUE; \
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); \
140 lResult = 0; \
141 if (IsMsgHandled()) \
142 return TRUE; \
145 // void OnSetFocus(CWindow wndOld)
146 #define CR_MSG_WM_SETFOCUS(func) \
147 if (uMsg == WM_SETFOCUS) { \
148 SetMsgHandled(TRUE); \
149 func((HWND)wParam); \
150 lResult = 0; \
151 if (IsMsgHandled()) \
152 return TRUE; \
155 // void OnKillFocus(CWindow wndFocus)
156 #define CR_MSG_WM_KILLFOCUS(func) \
157 if (uMsg == WM_KILLFOCUS) { \
158 SetMsgHandled(TRUE); \
159 func((HWND)wParam); \
160 lResult = 0; \
161 if (IsMsgHandled()) \
162 return TRUE; \
165 // void OnEnable(BOOL bEnable)
166 #define CR_MSG_WM_ENABLE(func) \
167 if (uMsg == WM_ENABLE) { \
168 SetMsgHandled(TRUE); \
169 func((BOOL)wParam); \
170 lResult = 0; \
171 if (IsMsgHandled()) \
172 return TRUE; \
175 // void OnPaint(CDCHandle dc)
176 #define CR_MSG_WM_PAINT(func) \
177 if (uMsg == WM_PAINT) { \
178 SetMsgHandled(TRUE); \
179 func((HDC)wParam); \
180 lResult = 0; \
181 if (IsMsgHandled()) \
182 return TRUE; \
185 // void OnClose()
186 #define CR_MSG_WM_CLOSE(func) \
187 if (uMsg == WM_CLOSE) { \
188 SetMsgHandled(TRUE); \
189 func(); \
190 lResult = 0; \
191 if (IsMsgHandled()) \
192 return TRUE; \
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()) \
201 return TRUE; \
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()) \
210 return TRUE; \
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()) \
219 return TRUE; \
222 // void OnSysColorChange()
223 #define CR_MSG_WM_SYSCOLORCHANGE(func) \
224 if (uMsg == WM_SYSCOLORCHANGE) { \
225 SetMsgHandled(TRUE); \
226 func(); \
227 lResult = 0; \
228 if (IsMsgHandled()) \
229 return TRUE; \
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); \
237 lResult = 0; \
238 if (IsMsgHandled()) \
239 return TRUE; \
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); \
247 lResult = 0; \
248 if (IsMsgHandled()) \
249 return TRUE; \
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()) \
258 return TRUE; \
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()) \
267 return TRUE; \
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()) \
276 return TRUE; \
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()) \
285 return TRUE; \
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()) \
294 return TRUE; \
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()) \
303 return TRUE; \
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); \
311 lResult = 0; \
312 if (IsMsgHandled()) \
313 return TRUE; \
316 // void OnDevModeChange(LPCTSTR lpDeviceName)
317 #define CR_MSG_WM_DEVMODECHANGE(func) \
318 if (uMsg == WM_DEVMODECHANGE) { \
319 SetMsgHandled(TRUE); \
320 func((LPCTSTR)lParam); \
321 lResult = 0; \
322 if (IsMsgHandled()) \
323 return TRUE; \
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); \
331 lResult = 0; \
332 if (IsMsgHandled()) \
333 return TRUE; \
336 // void OnFontChange()
337 #define CR_MSG_WM_FONTCHANGE(func) \
338 if (uMsg == WM_FONTCHANGE) { \
339 SetMsgHandled(TRUE); \
340 func(); \
341 lResult = 0; \
342 if (IsMsgHandled()) \
343 return TRUE; \
346 // void OnTimeChange()
347 #define CR_MSG_WM_TIMECHANGE(func) \
348 if (uMsg == WM_TIMECHANGE) { \
349 SetMsgHandled(TRUE); \
350 func(); \
351 lResult = 0; \
352 if (IsMsgHandled()) \
353 return TRUE; \
356 // void OnCancelMode()
357 #define CR_MSG_WM_CANCELMODE(func) \
358 if (uMsg == WM_CANCELMODE) { \
359 SetMsgHandled(TRUE); \
360 func(); \
361 lResult = 0; \
362 if (IsMsgHandled()) \
363 return TRUE; \
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()) \
373 return TRUE; \
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()) \
383 return TRUE; \
386 // void OnChildActivate()
387 #define CR_MSG_WM_CHILDACTIVATE(func) \
388 if (uMsg == WM_CHILDACTIVATE) { \
389 SetMsgHandled(TRUE); \
390 func(); \
391 lResult = 0; \
392 if (IsMsgHandled()) \
393 return TRUE; \
396 // void OnGetMinMaxInfo(LPMINMAXINFO lpMMI)
397 #define CR_MSG_WM_GETMINMAXINFO(func) \
398 if (uMsg == WM_GETMINMAXINFO) { \
399 SetMsgHandled(TRUE); \
400 func((LPMINMAXINFO)lParam); \
401 lResult = 0; \
402 if (IsMsgHandled()) \
403 return TRUE; \
406 // void OnIconEraseBkgnd(CDCHandle dc)
407 #define CR_MSG_WM_ICONERASEBKGND(func) \
408 if (uMsg == WM_ICONERASEBKGND) { \
409 SetMsgHandled(TRUE); \
410 func((HDC)wParam); \
411 lResult = 0; \
412 if (IsMsgHandled()) \
413 return TRUE; \
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)); \
421 lResult = 0; \
422 if (IsMsgHandled()) \
423 return TRUE; \
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); \
431 lResult = TRUE; \
432 if (IsMsgHandled()) \
433 return TRUE; \
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); \
441 lResult = TRUE; \
442 if (IsMsgHandled()) \
443 return TRUE; \
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); \
451 lResult = TRUE; \
452 if (IsMsgHandled()) \
453 return TRUE; \
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()) \
463 return TRUE; \
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()) \
473 return TRUE; \
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()) \
482 return TRUE; \
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()) \
491 return TRUE; \
494 // void OnCompacting(UINT nCpuTime)
495 #define CR_MSG_WM_COMPACTING(func) \
496 if (uMsg == WM_COMPACTING) { \
497 SetMsgHandled(TRUE); \
498 func((UINT)wParam); \
499 lResult = 0; \
500 if (IsMsgHandled()) \
501 return TRUE; \
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()) \
510 return TRUE; \
513 // void OnNcDestroy()
514 #define CR_MSG_WM_NCDESTROY(func) \
515 if (uMsg == WM_NCDESTROY) { \
516 SetMsgHandled(TRUE); \
517 func(); \
518 lResult = 0; \
519 if (IsMsgHandled()) \
520 return TRUE; \
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()) \
529 return TRUE; \
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()) \
539 return TRUE; \
542 // void OnNcPaint(CRgn rgn)
543 #define CR_MSG_WM_NCPAINT(func) \
544 if (uMsg == WM_NCPAINT) { \
545 SetMsgHandled(TRUE); \
546 func((HRGN)wParam); \
547 lResult = 0; \
548 if (IsMsgHandled()) \
549 return TRUE; \
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()) \
558 return TRUE; \
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()) \
567 return TRUE; \
570 // void OnNcMouseMove(UINT nHitTest, gfx::Point point)
571 #define CR_MSG_WM_NCMOUSEMOVE(func) \
572 if (uMsg == WM_NCMOUSEMOVE) { \
573 SetMsgHandled(TRUE); \
574 func((UINT)wParam, \
575 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
576 lResult = 0; \
577 if (IsMsgHandled()) \
578 return TRUE; \
581 // void OnNcLButtonDown(UINT nHitTest, gfx::Point point)
582 #define CR_MSG_WM_NCLBUTTONDOWN(func) \
583 if (uMsg == WM_NCLBUTTONDOWN) { \
584 SetMsgHandled(TRUE); \
585 func((UINT)wParam, \
586 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
587 lResult = 0; \
588 if (IsMsgHandled()) \
589 return TRUE; \
592 // void OnNcLButtonUp(UINT nHitTest, gfx::Point point)
593 #define CR_MSG_WM_NCLBUTTONUP(func) \
594 if (uMsg == WM_NCLBUTTONUP) { \
595 SetMsgHandled(TRUE); \
596 func((UINT)wParam, \
597 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
598 lResult = 0; \
599 if (IsMsgHandled()) \
600 return TRUE; \
603 // void OnNcLButtonDblClk(UINT nHitTest, gfx::Point point)
604 #define CR_MSG_WM_NCLBUTTONDBLCLK(func) \
605 if (uMsg == WM_NCLBUTTONDBLCLK) { \
606 SetMsgHandled(TRUE); \
607 func((UINT)wParam, \
608 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
609 lResult = 0; \
610 if (IsMsgHandled()) \
611 return TRUE; \
614 // void OnNcRButtonDown(UINT nHitTest, gfx::Point point)
615 #define CR_MSG_WM_NCRBUTTONDOWN(func) \
616 if (uMsg == WM_NCRBUTTONDOWN) { \
617 SetMsgHandled(TRUE); \
618 func((UINT)wParam, \
619 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
620 lResult = 0; \
621 if (IsMsgHandled()) \
622 return TRUE; \
625 // void OnNcRButtonUp(UINT nHitTest, gfx::Point point)
626 #define CR_MSG_WM_NCRBUTTONUP(func) \
627 if (uMsg == WM_NCRBUTTONUP) { \
628 SetMsgHandled(TRUE); \
629 func((UINT)wParam, \
630 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
631 lResult = 0; \
632 if (IsMsgHandled()) \
633 return TRUE; \
636 // void OnNcRButtonDblClk(UINT nHitTest, CPoint point)
637 #define CR_MSG_WM_NCRBUTTONDBLCLK(func) \
638 if (uMsg == WM_NCRBUTTONDBLCLK) { \
639 SetMsgHandled(TRUE); \
640 func((UINT)wParam, \
641 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
642 lResult = 0; \
643 if (IsMsgHandled()) \
644 return TRUE; \
647 // void OnNcMButtonDown(UINT nHitTest, CPoint point)
648 #define CR_MSG_WM_NCMBUTTONDOWN(func) \
649 if (uMsg == WM_NCMBUTTONDOWN) { \
650 SetMsgHandled(TRUE); \
651 func((UINT)wParam, \
652 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
653 lResult = 0; \
654 if (IsMsgHandled()) \
655 return TRUE; \
658 // void OnNcMButtonUp(UINT nHitTest, CPoint point)
659 #define CR_MSG_WM_NCMBUTTONUP(func) \
660 if (uMsg == WM_NCMBUTTONUP) { \
661 SetMsgHandled(TRUE); \
662 func((UINT)wParam, \
663 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
664 lResult = 0; \
665 if (IsMsgHandled()) \
666 return TRUE; \
669 // void OnNcMButtonDblClk(UINT nHitTest, CPoint point)
670 #define CR_MSG_WM_NCMBUTTONDBLCLK(func) \
671 if (uMsg == WM_NCMBUTTONDBLCLK) { \
672 SetMsgHandled(TRUE); \
673 func((UINT)wParam, \
674 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
675 lResult = 0; \
676 if (IsMsgHandled()) \
677 return TRUE; \
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)); \
687 lResult = 0; \
688 if (IsMsgHandled()) \
689 return TRUE; \
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)); \
699 lResult = 0; \
700 if (IsMsgHandled()) \
701 return TRUE; \
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)); \
711 lResult = 0; \
712 if (IsMsgHandled()) \
713 return TRUE; \
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)); \
723 lResult = 0; \
724 if (IsMsgHandled()) \
725 return TRUE; \
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)); \
735 lResult = 0; \
736 if (IsMsgHandled()) \
737 return TRUE; \
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)); \
747 lResult = 0; \
748 if (IsMsgHandled()) \
749 return TRUE; \
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)); \
759 lResult = 0; \
760 if (IsMsgHandled()) \
761 return TRUE; \
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)); \
771 lResult = 0; \
772 if (IsMsgHandled()) \
773 return TRUE; \
776 // void OnSysCommand(UINT nID, LPARAM lParam)
777 #define CR_MSG_WM_SYSCOMMAND(func) \
778 if (uMsg == WM_SYSCOMMAND) { \
779 SetMsgHandled(TRUE); \
780 func((UINT)wParam, \
781 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
782 lResult = 0; \
783 if (IsMsgHandled()) \
784 return TRUE; \
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); \
792 lResult = 0; \
793 if (IsMsgHandled()) \
794 return TRUE; \
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); \
802 lResult = 0; \
803 if (IsMsgHandled()) \
804 return TRUE; \
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); \
812 lResult = 0; \
813 if (IsMsgHandled()) \
814 return TRUE; \
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); \
822 lResult = 0; \
823 if (IsMsgHandled()) \
824 return TRUE; \
827 // void OnInitMenu(CMenu menu)
828 #define CR_MSG_WM_INITMENU(func) \
829 if (uMsg == WM_INITMENU) { \
830 SetMsgHandled(TRUE); \
831 func((HMENU)wParam); \
832 lResult = 0; \
833 if (IsMsgHandled()) \
834 return TRUE; \
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)); \
842 lResult = 0; \
843 if (IsMsgHandled()) \
844 return TRUE; \
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); \
852 lResult = 0; \
853 if (IsMsgHandled()) \
854 return TRUE; \
857 // LRESULT OnMenuChar(UINT nChar, UINT nFlags, CMenu menu)
858 #define CR_MSG_WM_MENUCHAR(func) \
859 if (uMsg == WM_MENUCHAR) { \
860 SetMsgHandled(TRUE); \
861 lResult = \
862 func((TCHAR)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \
863 if (IsMsgHandled()) \
864 return TRUE; \
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()) \
873 return TRUE; \
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); \
881 lResult = 0; \
882 if (IsMsgHandled()) \
883 return TRUE; \
886 // void OnMouseMove(UINT nFlags, CPoint point)
887 #define CR_MSG_WM_MOUSEMOVE(func) \
888 if (uMsg == WM_MOUSEMOVE) { \
889 SetMsgHandled(TRUE); \
890 func((UINT)wParam, \
891 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
892 lResult = 0; \
893 if (IsMsgHandled()) \
894 return TRUE; \
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()) \
906 return TRUE; \
909 // void OnLButtonDown(UINT nFlags, CPoint point)
910 #define CR_MSG_WM_LBUTTONDOWN(func) \
911 if (uMsg == WM_LBUTTONDOWN) { \
912 SetMsgHandled(TRUE); \
913 func((UINT)wParam, \
914 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
915 lResult = 0; \
916 if (IsMsgHandled()) \
917 return TRUE; \
920 // void OnLButtonUp(UINT nFlags, CPoint point)
921 #define CR_MSG_WM_LBUTTONUP(func) \
922 if (uMsg == WM_LBUTTONUP) { \
923 SetMsgHandled(TRUE); \
924 func((UINT)wParam, \
925 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
926 lResult = 0; \
927 if (IsMsgHandled()) \
928 return TRUE; \
931 // void OnLButtonDblClk(UINT nFlags, CPoint point)
932 #define CR_MSG_WM_LBUTTONDBLCLK(func) \
933 if (uMsg == WM_LBUTTONDBLCLK) { \
934 SetMsgHandled(TRUE); \
935 func((UINT)wParam, \
936 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
937 lResult = 0; \
938 if (IsMsgHandled()) \
939 return TRUE; \
942 // void OnRButtonDown(UINT nFlags, CPoint point)
943 #define CR_MSG_WM_RBUTTONDOWN(func) \
944 if (uMsg == WM_RBUTTONDOWN) { \
945 SetMsgHandled(TRUE); \
946 func((UINT)wParam, \
947 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
948 lResult = 0; \
949 if (IsMsgHandled()) \
950 return TRUE; \
953 // void OnRButtonUp(UINT nFlags, CPoint point)
954 #define CR_MSG_WM_RBUTTONUP(func) \
955 if (uMsg == WM_RBUTTONUP) { \
956 SetMsgHandled(TRUE); \
957 func((UINT)wParam, \
958 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
959 lResult = 0; \
960 if (IsMsgHandled()) \
961 return TRUE; \
964 // void OnRButtonDblClk(UINT nFlags, CPoint point)
965 #define CR_MSG_WM_RBUTTONDBLCLK(func) \
966 if (uMsg == WM_RBUTTONDBLCLK) { \
967 SetMsgHandled(TRUE); \
968 func((UINT)wParam, \
969 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
970 lResult = 0; \
971 if (IsMsgHandled()) \
972 return TRUE; \
975 // void OnMButtonDown(UINT nFlags, CPoint point)
976 #define CR_MSG_WM_MBUTTONDOWN(func) \
977 if (uMsg == WM_MBUTTONDOWN) { \
978 SetMsgHandled(TRUE); \
979 func((UINT)wParam, \
980 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
981 lResult = 0; \
982 if (IsMsgHandled()) \
983 return TRUE; \
986 // void OnMButtonUp(UINT nFlags, CPoint point)
987 #define CR_MSG_WM_MBUTTONUP(func) \
988 if (uMsg == WM_MBUTTONUP) { \
989 SetMsgHandled(TRUE); \
990 func((UINT)wParam, \
991 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
992 lResult = 0; \
993 if (IsMsgHandled()) \
994 return TRUE; \
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))); \
1003 lResult = 0; \
1004 if (IsMsgHandled()) \
1005 return TRUE; \
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); \
1013 lResult = 0; \
1014 if (IsMsgHandled()) \
1015 return TRUE; \
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); \
1023 lResult = 0; \
1024 if (IsMsgHandled()) \
1025 return TRUE; \
1028 // void OnRenderFormat(UINT nFormat)
1029 #define CR_MSG_WM_RENDERFORMAT(func) \
1030 if (uMsg == WM_RENDERFORMAT) { \
1031 SetMsgHandled(TRUE); \
1032 func((UINT)wParam); \
1033 lResult = 0; \
1034 if (IsMsgHandled()) \
1035 return TRUE; \
1038 // void OnRenderAllFormats()
1039 #define CR_MSG_WM_RENDERALLFORMATS(func) \
1040 if (uMsg == WM_RENDERALLFORMATS) { \
1041 SetMsgHandled(TRUE); \
1042 func(); \
1043 lResult = 0; \
1044 if (IsMsgHandled()) \
1045 return TRUE; \
1048 // void OnDestroyClipboard()
1049 #define CR_MSG_WM_DESTROYCLIPBOARD(func) \
1050 if (uMsg == WM_DESTROYCLIPBOARD) { \
1051 SetMsgHandled(TRUE); \
1052 func(); \
1053 lResult = 0; \
1054 if (IsMsgHandled()) \
1055 return TRUE; \
1058 // void OnDrawClipboard()
1059 #define CR_MSG_WM_DRAWCLIPBOARD(func) \
1060 if (uMsg == WM_DRAWCLIPBOARD) { \
1061 SetMsgHandled(TRUE); \
1062 func(); \
1063 lResult = 0; \
1064 if (IsMsgHandled()) \
1065 return TRUE; \
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); \
1074 lResult = 0; \
1075 if (IsMsgHandled()) \
1076 return TRUE; \
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)); \
1084 lResult = 0; \
1085 if (IsMsgHandled()) \
1086 return TRUE; \
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))); \
1095 lResult = 0; \
1096 if (IsMsgHandled()) \
1097 return TRUE; \
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); \
1106 lResult = 0; \
1107 if (IsMsgHandled()) \
1108 return TRUE; \
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); \
1116 lResult = 0; \
1117 if (IsMsgHandled()) \
1118 return TRUE; \
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); \
1126 lResult = 0; \
1127 if (IsMsgHandled()) \
1128 return TRUE; \
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)); \
1136 lResult = 0; \
1137 if (IsMsgHandled()) \
1138 return TRUE; \
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()) \
1147 return TRUE; \
1150 // void OnPaletteChanged(CWindow wndFocus)
1151 #define CR_MSG_WM_PALETTECHANGED(func) \
1152 if (uMsg == WM_PALETTECHANGED) { \
1153 SetMsgHandled(TRUE); \
1154 func((HWND)wParam); \
1155 lResult = 0; \
1156 if (IsMsgHandled()) \
1157 return TRUE; \
1160 // void OnPaletteIsChanging(CWindow wndPalChg)
1161 #define CR_MSG_WM_PALETTEISCHANGING(func) \
1162 if (uMsg == WM_PALETTEISCHANGING) { \
1163 SetMsgHandled(TRUE); \
1164 func((HWND)wParam); \
1165 lResult = 0; \
1166 if (IsMsgHandled()) \
1167 return TRUE; \
1170 // void OnDropFiles(HDROP hDropInfo)
1171 #define CR_MSG_WM_DROPFILES(func) \
1172 if (uMsg == WM_DROPFILES) { \
1173 SetMsgHandled(TRUE); \
1174 func((HDROP)wParam); \
1175 lResult = 0; \
1176 if (IsMsgHandled()) \
1177 return TRUE; \
1180 // void OnWindowPosChanging(LPWINDOWPOS lpWndPos)
1181 #define CR_MSG_WM_WINDOWPOSCHANGING(func) \
1182 if (uMsg == WM_WINDOWPOSCHANGING) { \
1183 SetMsgHandled(TRUE); \
1184 func((LPWINDOWPOS)lParam); \
1185 lResult = 0; \
1186 if (IsMsgHandled()) \
1187 return TRUE; \
1190 // void OnWindowPosChanged(LPWINDOWPOS lpWndPos)
1191 #define CR_MSG_WM_WINDOWPOSCHANGED(func) \
1192 if (uMsg == WM_WINDOWPOSCHANGED) { \
1193 SetMsgHandled(TRUE); \
1194 func((LPWINDOWPOS)lParam); \
1195 lResult = 0; \
1196 if (IsMsgHandled()) \
1197 return TRUE; \
1200 // void OnExitMenuLoop(BOOL fIsTrackPopupMenu)
1201 #define CR_MSG_WM_EXITMENULOOP(func) \
1202 if (uMsg == WM_EXITMENULOOP) { \
1203 SetMsgHandled(TRUE); \
1204 func((BOOL)wParam); \
1205 lResult = 0; \
1206 if (IsMsgHandled()) \
1207 return TRUE; \
1210 // void OnEnterMenuLoop(BOOL fIsTrackPopupMenu)
1211 #define CR_MSG_WM_ENTERMENULOOP(func) \
1212 if (uMsg == WM_ENTERMENULOOP) { \
1213 SetMsgHandled(TRUE); \
1214 func((BOOL)wParam); \
1215 lResult = 0; \
1216 if (IsMsgHandled()) \
1217 return TRUE; \
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); \
1225 lResult = 0; \
1226 if (IsMsgHandled()) \
1227 return TRUE; \
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); \
1235 lResult = 0; \
1236 if (IsMsgHandled()) \
1237 return TRUE; \
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); \
1245 lResult = TRUE; \
1246 if (IsMsgHandled()) \
1247 return TRUE; \
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); \
1255 lResult = TRUE; \
1256 if (IsMsgHandled()) \
1257 return TRUE; \
1260 // void OnCaptureChanged(CWindow wnd)
1261 #define CR_MSG_WM_CAPTURECHANGED(func) \
1262 if (uMsg == WM_CAPTURECHANGED) { \
1263 SetMsgHandled(TRUE); \
1264 func((HWND)lParam); \
1265 lResult = 0; \
1266 if (IsMsgHandled()) \
1267 return TRUE; \
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()) \
1276 return TRUE; \
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); \
1284 lResult = 0; \
1285 if (IsMsgHandled()) \
1286 return TRUE; \
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))); \
1295 lResult = 0; \
1296 if (IsMsgHandled()) \
1297 return TRUE; \
1300 // void OnEnterSizeMove()
1301 #define CR_MSG_WM_ENTERSIZEMOVE(func) \
1302 if (uMsg == WM_ENTERSIZEMOVE) { \
1303 SetMsgHandled(TRUE); \
1304 func(); \
1305 lResult = 0; \
1306 if (IsMsgHandled()) \
1307 return TRUE; \
1310 // void OnExitSizeMove()
1311 #define CR_MSG_WM_EXITSIZEMOVE(func) \
1312 if (uMsg == WM_EXITSIZEMOVE) { \
1313 SetMsgHandled(TRUE); \
1314 func(); \
1315 lResult = 0; \
1316 if (IsMsgHandled()) \
1317 return TRUE; \
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()) \
1326 return TRUE; \
1329 // LRESULT OnGetHotKey()
1330 #define CR_MSG_WM_GETHOTKEY(func) \
1331 if (uMsg == WM_GETHOTKEY) { \
1332 SetMsgHandled(TRUE); \
1333 lResult = func(); \
1334 if (IsMsgHandled()) \
1335 return TRUE; \
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()) \
1344 return TRUE; \
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()) \
1353 return TRUE; \
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()) \
1362 return TRUE; \
1365 // void OnHelp(LPHELPINFO lpHelpInfo)
1366 #define CR_MSG_WM_HELP(func) \
1367 if (uMsg == WM_HELP) { \
1368 SetMsgHandled(TRUE); \
1369 func((LPHELPINFO)lParam); \
1370 lResult = TRUE; \
1371 if (IsMsgHandled()) \
1372 return TRUE; \
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)); \
1380 lResult = 0; \
1381 if (IsMsgHandled()) \
1382 return TRUE; \
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); \
1390 lResult = TRUE; \
1391 if (IsMsgHandled()) \
1392 return TRUE; \
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); \
1400 lResult = 0; \
1401 if (IsMsgHandled()) \
1402 return TRUE; \
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); \
1410 lResult = 0; \
1411 if (IsMsgHandled()) \
1412 return TRUE; \
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); \
1420 lResult = 0; \
1421 if (IsMsgHandled()) \
1422 return TRUE; \
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()) \
1431 return TRUE; \
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()) \
1440 return TRUE; \
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); \
1448 lResult = 0; \
1449 if (IsMsgHandled()) \
1450 return TRUE; \
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); \
1458 lResult = 0; \
1459 if (IsMsgHandled()) \
1460 return TRUE; \
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); \
1468 lResult = TRUE; \
1469 if (IsMsgHandled()) \
1470 return TRUE; \
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)); \
1478 lResult = 0; \
1479 if (IsMsgHandled()) \
1480 return TRUE; \
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()) \
1490 return TRUE; \
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()) \
1499 return TRUE; \
1502 // void OnSetRedraw(BOOL bRedraw)
1503 #define CR_MSG_WM_SETREDRAW(func) \
1504 if (uMsg == WM_SETREDRAW) { \
1505 SetMsgHandled(TRUE); \
1506 func((BOOL)wParam); \
1507 lResult = 0; \
1508 if (IsMsgHandled()) \
1509 return TRUE; \
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()) \
1518 return TRUE; \
1521 // void OnUserChanged()
1522 #define CR_MSG_WM_USERCHANGED(func) \
1523 if (uMsg == WM_USERCHANGED) { \
1524 SetMsgHandled(TRUE); \
1525 func(); \
1526 lResult = 0; \
1527 if (IsMsgHandled()) \
1528 return TRUE; \
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); \
1540 func(wParam, \
1541 gfx::Point(CR_GET_X_LPARAM(lParam), CR_GET_Y_LPARAM(lParam))); \
1542 lResult = 0; \
1543 if (IsMsgHandled()) \
1544 return TRUE; \
1547 // void OnMouseLeave()
1548 #define CR_MSG_WM_MOUSELEAVE(func) \
1549 if (uMsg == WM_MOUSELEAVE) { \
1550 SetMsgHandled(TRUE); \
1551 func(); \
1552 lResult = 0; \
1553 if (IsMsgHandled()) \
1554 return TRUE; \
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); \
1566 lResult = 0; \
1567 if (IsMsgHandled()) \
1568 return TRUE; \
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()) \
1577 return TRUE; \
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()) \
1586 return TRUE; \
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); \
1594 lResult = 0; \
1595 if (IsMsgHandled()) \
1596 return TRUE; \
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); \
1604 lResult = 0; \
1605 if (IsMsgHandled()) \
1606 return TRUE; \
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()) \
1622 return TRUE; \
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))); \
1632 lResult = 0; \
1633 if (IsMsgHandled()) \
1634 return TRUE; \
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))); \
1644 lResult = 0; \
1645 if (IsMsgHandled()) \
1646 return TRUE; \
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))); \
1656 lResult = 0; \
1657 if (IsMsgHandled()) \
1658 return TRUE; \
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))); \
1668 lResult = 0; \
1669 if (IsMsgHandled()) \
1670 return TRUE; \
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))); \
1680 lResult = 0; \
1681 if (IsMsgHandled()) \
1682 return TRUE; \
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))); \
1692 lResult = 0; \
1693 if (IsMsgHandled()) \
1694 return TRUE; \
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)); \
1702 lResult = 0; \
1703 if (IsMsgHandled()) \
1704 return TRUE; \
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)); \
1712 lResult = 0; \
1713 if (IsMsgHandled()) \
1714 return TRUE; \
1717 // LRESULT OnQueryUIState()
1718 #define CR_MSG_WM_QUERYUISTATE(func) \
1719 if (uMsg == WM_QUERYUISTATE) { \
1720 SetMsgHandled(TRUE); \
1721 lResult = func(); \
1722 if (IsMsgHandled()) \
1723 return TRUE; \
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); \
1735 lResult = 0; \
1736 if (IsMsgHandled()) \
1737 return TRUE; \
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; \
1749 return TRUE; \
1753 // OnThemeChanged()
1754 #define CR_MSG_WM_THEMECHANGED(func) \
1755 if (uMsg == WM_THEMECHANGED) { \
1756 SetMsgHandled(TRUE); \
1757 func(); \
1758 lResult = 0; \
1759 if (IsMsgHandled()) \
1760 return TRUE; \
1763 #endif /* _WIN32_WINNT >= 0x0501 */
1765 ///////////////////////////////////////////////////////////////////////////////
1766 // ATL defined messages
1768 // BOOL OnForwardMsg(LPMSG Msg, DWORD nUserData)
1769 #define CR_MSG_WM_FORWARDMSG(func) \
1770 if (uMsg == WM_FORWARDMSG) { \
1771 SetMsgHandled(TRUE); \
1772 lResult = (LRESULT)func((LPMSG)lParam, (DWORD)wParam); \
1773 if (IsMsgHandled()) \
1774 return TRUE; \
1777 ///////////////////////////////////////////////////////////////////////////////
1778 // Dialog specific messages
1780 // LRESULT OnDMGetDefID()
1781 #define MSG_DM_GETDEFID(func) \
1782 if (uMsg == DM_GETDEFID) { \
1783 SetMsgHandled(TRUE); \
1784 lResult = func(); \
1785 if (IsMsgHandled()) \
1786 return TRUE; \
1789 // void OnDMSetDefID(UINT DefID)
1790 #define MSG_DM_SETDEFID(func) \
1791 if (uMsg == DM_SETDEFID) { \
1792 SetMsgHandled(TRUE); \
1793 func((UINT)wParam); \
1794 lResult = TRUE; \
1795 if (IsMsgHandled()) \
1796 return TRUE; \
1799 // void OnDMReposition()
1800 #define MSG_DM_REPOSITION(func) \
1801 if (uMsg == DM_REPOSITION) { \
1802 SetMsgHandled(TRUE); \
1803 func(); \
1804 lResult = 0; \
1805 if (IsMsgHandled()) \
1806 return TRUE; \
1809 ///////////////////////////////////////////////////////////////////////////////
1810 // Reflected messages
1812 // void OnReflectedCommand(UINT uNotifyCode, int nID, CWindow wndCtl)
1813 #define MSG_OCM_COMMAND(func) \
1814 if (uMsg == OCM_COMMAND) { \
1815 SetMsgHandled(TRUE); \
1816 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
1817 lResult = 0; \
1818 if (IsMsgHandled()) \
1819 return TRUE; \
1822 // LRESULT OnReflectedNotify(int idCtrl, LPNMHDR pnmh)
1823 #define MSG_OCM_NOTIFY(func) \
1824 if (uMsg == OCM_NOTIFY) { \
1825 SetMsgHandled(TRUE); \
1826 lResult = func((int)wParam, (LPNMHDR)lParam); \
1827 if (IsMsgHandled()) \
1828 return TRUE; \
1831 // void OnReflectedParentNotify(UINT message, UINT nChildID, LPARAM lParam)
1832 #define MSG_OCM_PARENTNOTIFY(func) \
1833 if (uMsg == OCM_PARENTNOTIFY) { \
1834 SetMsgHandled(TRUE); \
1835 func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \
1836 lResult = 0; \
1837 if (IsMsgHandled()) \
1838 return TRUE; \
1841 // void OnReflectedDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
1842 #define MSG_OCM_DRAWITEM(func) \
1843 if (uMsg == OCM_DRAWITEM) { \
1844 SetMsgHandled(TRUE); \
1845 func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \
1846 lResult = TRUE; \
1847 if (IsMsgHandled()) \
1848 return TRUE; \
1851 // void OnReflectedMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT
1852 // lpMeasureItemStruct)
1853 #define MSG_OCM_MEASUREITEM(func) \
1854 if (uMsg == OCM_MEASUREITEM) { \
1855 SetMsgHandled(TRUE); \
1856 func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \
1857 lResult = TRUE; \
1858 if (IsMsgHandled()) \
1859 return TRUE; \
1862 // int OnReflectedCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT
1863 // lpCompareItemStruct)
1864 #define MSG_OCM_COMPAREITEM(func) \
1865 if (uMsg == OCM_COMPAREITEM) { \
1866 SetMsgHandled(TRUE); \
1867 lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \
1868 if (IsMsgHandled()) \
1869 return TRUE; \
1872 // void OnReflectedDeleteItem(int nIDCtl, LPDELETEITEMSTRUCT lpDeleteItemStruct)
1873 #define MSG_OCM_DELETEITEM(func) \
1874 if (uMsg == OCM_DELETEITEM) { \
1875 SetMsgHandled(TRUE); \
1876 func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \
1877 lResult = TRUE; \
1878 if (IsMsgHandled()) \
1879 return TRUE; \
1882 // int OnReflectedVKeyToItem(UINT nKey, UINT nIndex, CListBox listBox)
1883 #define MSG_OCM_VKEYTOITEM(func) \
1884 if (uMsg == OCM_VKEYTOITEM) { \
1885 SetMsgHandled(TRUE); \
1886 lResult = (LRESULT)func( \
1887 (UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
1888 if (IsMsgHandled()) \
1889 return TRUE; \
1892 // int OnReflectedCharToItem(UINT nChar, UINT nIndex, CListBox listBox)
1893 #define MSG_OCM_CHARTOITEM(func) \
1894 if (uMsg == OCM_CHARTOITEM) { \
1895 SetMsgHandled(TRUE); \
1896 lResult = (LRESULT)func( \
1897 (UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
1898 if (IsMsgHandled()) \
1899 return TRUE; \
1902 // void OnReflectedHScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
1903 #define MSG_OCM_HSCROLL(func) \
1904 if (uMsg == OCM_HSCROLL) { \
1905 SetMsgHandled(TRUE); \
1906 func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
1907 lResult = 0; \
1908 if (IsMsgHandled()) \
1909 return TRUE; \
1912 // void OnReflectedVScroll(UINT nSBCode, UINT nPos, CScrollBar pScrollBar)
1913 #define MSG_OCM_VSCROLL(func) \
1914 if (uMsg == OCM_VSCROLL) { \
1915 SetMsgHandled(TRUE); \
1916 func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
1917 lResult = 0; \
1918 if (IsMsgHandled()) \
1919 return TRUE; \
1922 // HBRUSH OnReflectedCtlColorEdit(CDCHandle dc, CEdit edit)
1923 #define MSG_OCM_CTLCOLOREDIT(func) \
1924 if (uMsg == OCM_CTLCOLOREDIT) { \
1925 SetMsgHandled(TRUE); \
1926 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
1927 if (IsMsgHandled()) \
1928 return TRUE; \
1931 // HBRUSH OnReflectedCtlColorListBox(CDCHandle dc, CListBox listBox)
1932 #define MSG_OCM_CTLCOLORLISTBOX(func) \
1933 if (uMsg == OCM_CTLCOLORLISTBOX) { \
1934 SetMsgHandled(TRUE); \
1935 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
1936 if (IsMsgHandled()) \
1937 return TRUE; \
1940 // HBRUSH OnReflectedCtlColorBtn(CDCHandle dc, CButton button)
1941 #define MSG_OCM_CTLCOLORBTN(func) \
1942 if (uMsg == OCM_CTLCOLORBTN) { \
1943 SetMsgHandled(TRUE); \
1944 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
1945 if (IsMsgHandled()) \
1946 return TRUE; \
1949 // HBRUSH OnReflectedCtlColorDlg(CDCHandle dc, CWindow wnd)
1950 #define MSG_OCM_CTLCOLORDLG(func) \
1951 if (uMsg == OCM_CTLCOLORDLG) { \
1952 SetMsgHandled(TRUE); \
1953 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
1954 if (IsMsgHandled()) \
1955 return TRUE; \
1958 // HBRUSH OnReflectedCtlColorScrollBar(CDCHandle dc, CScrollBar scrollBar)
1959 #define MSG_OCM_CTLCOLORSCROLLBAR(func) \
1960 if (uMsg == OCM_CTLCOLORSCROLLBAR) { \
1961 SetMsgHandled(TRUE); \
1962 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
1963 if (IsMsgHandled()) \
1964 return TRUE; \
1967 // HBRUSH OnReflectedCtlColorStatic(CDCHandle dc, CStatic wndStatic)
1968 #define MSG_OCM_CTLCOLORSTATIC(func) \
1969 if (uMsg == OCM_CTLCOLORSTATIC) { \
1970 SetMsgHandled(TRUE); \
1971 lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
1972 if (IsMsgHandled()) \
1973 return TRUE; \
1976 ///////////////////////////////////////////////////////////////////////////////
1977 // Edit specific messages
1979 // void OnClear()
1980 #define CR_MSG_WM_CLEAR(func) \
1981 if (uMsg == WM_CLEAR) { \
1982 SetMsgHandled(TRUE); \
1983 func(); \
1984 lResult = 0; \
1985 if (IsMsgHandled()) \
1986 return TRUE; \
1989 // void OnCopy()
1990 #define CR_MSG_WM_COPY(func) \
1991 if (uMsg == WM_COPY) { \
1992 SetMsgHandled(TRUE); \
1993 func(); \
1994 lResult = 0; \
1995 if (IsMsgHandled()) \
1996 return TRUE; \
1999 // void OnCut()
2000 #define CR_MSG_WM_CUT(func) \
2001 if (uMsg == WM_CUT) { \
2002 SetMsgHandled(TRUE); \
2003 func(); \
2004 lResult = 0; \
2005 if (IsMsgHandled()) \
2006 return TRUE; \
2009 // void OnPaste()
2010 #define CR_MSG_WM_PASTE(func) \
2011 if (uMsg == WM_PASTE) { \
2012 SetMsgHandled(TRUE); \
2013 func(); \
2014 lResult = 0; \
2015 if (IsMsgHandled()) \
2016 return TRUE; \
2019 // void OnUndo()
2020 #define CR_MSG_WM_UNDO(func) \
2021 if (uMsg == WM_UNDO) { \
2022 SetMsgHandled(TRUE); \
2023 func(); \
2024 lResult = 0; \
2025 if (IsMsgHandled()) \
2026 return TRUE; \
2029 ///////////////////////////////////////////////////////////////////////////////
2030 // Generic message handlers
2032 // LRESULT OnMessageHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam)
2033 #define CR_MESSAGE_HANDLER_EX(msg, func) \
2034 if (uMsg == msg) { \
2035 SetMsgHandled(TRUE); \
2036 lResult = func(uMsg, wParam, lParam); \
2037 if (IsMsgHandled()) \
2038 return TRUE; \
2041 // LRESULT OnMessageRangeHandlerEX(UINT uMsg, WPARAM wParam, LPARAM lParam)
2042 #define CR_MESSAGE_RANGE_HANDLER_EX(msgFirst, msgLast, func) \
2043 if (uMsg >= msgFirst && uMsg <= msgLast) { \
2044 SetMsgHandled(TRUE); \
2045 lResult = func(uMsg, wParam, lParam); \
2046 if (IsMsgHandled()) \
2047 return TRUE; \
2050 ///////////////////////////////////////////////////////////////////////////////
2051 // Commands and notifications
2053 // void OnCommandHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2054 #define CR_COMMAND_HANDLER_EX(id, code, func) \
2055 if (uMsg == WM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) { \
2056 SetMsgHandled(TRUE); \
2057 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2058 lResult = 0; \
2059 if (IsMsgHandled()) \
2060 return TRUE; \
2063 // void OnCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2064 #define CR_COMMAND_ID_HANDLER_EX(id, func) \
2065 if (uMsg == WM_COMMAND && id == LOWORD(wParam)) { \
2066 SetMsgHandled(TRUE); \
2067 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2068 lResult = 0; \
2069 if (IsMsgHandled()) \
2070 return TRUE; \
2073 // void OnCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2074 #define CR_COMMAND_CODE_HANDLER_EX(code, func) \
2075 if (uMsg == WM_COMMAND && code == HIWORD(wParam)) { \
2076 SetMsgHandled(TRUE); \
2077 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2078 lResult = 0; \
2079 if (IsMsgHandled()) \
2080 return TRUE; \
2083 // LRESULT OnNotifyHandlerEX(LPNMHDR pnmh)
2084 #define CR_NOTIFY_HANDLER_EX(id, cd, func) \
2085 if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && \
2086 id == ((LPNMHDR)lParam)->idFrom) { \
2087 SetMsgHandled(TRUE); \
2088 lResult = func((LPNMHDR)lParam); \
2089 if (IsMsgHandled()) \
2090 return TRUE; \
2093 // LRESULT OnNotifyIDHandlerEX(LPNMHDR pnmh)
2094 #define CR_NOTIFY_ID_HANDLER_EX(id, func) \
2095 if (uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) { \
2096 SetMsgHandled(TRUE); \
2097 lResult = func((LPNMHDR)lParam); \
2098 if (IsMsgHandled()) \
2099 return TRUE; \
2102 // LRESULT OnNotifyCodeHandlerEX(LPNMHDR pnmh)
2103 #define CR_NOTIFY_CODE_HANDLER_EX(cd, func) \
2104 if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) { \
2105 SetMsgHandled(TRUE); \
2106 lResult = func((LPNMHDR)lParam); \
2107 if (IsMsgHandled()) \
2108 return TRUE; \
2111 // void OnCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2112 #define CR_COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \
2113 if (uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && \
2114 LOWORD(wParam) <= idLast) { \
2115 SetMsgHandled(TRUE); \
2116 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2117 lResult = 0; \
2118 if (IsMsgHandled()) \
2119 return TRUE; \
2122 // void OnCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow wndCtl)
2123 #define CR_COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \
2124 if (uMsg == WM_COMMAND && code == HIWORD(wParam) && \
2125 LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) { \
2126 SetMsgHandled(TRUE); \
2127 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2128 lResult = 0; \
2129 if (IsMsgHandled()) \
2130 return TRUE; \
2133 // LRESULT OnNotifyRangeHandlerEX(LPNMHDR pnmh)
2134 #define CR_NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \
2135 if (uMsg == WM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && \
2136 ((LPNMHDR)lParam)->idFrom <= idLast) { \
2137 SetMsgHandled(TRUE); \
2138 lResult = func((LPNMHDR)lParam); \
2139 if (IsMsgHandled()) \
2140 return TRUE; \
2143 // LRESULT OnNotifyRangeCodeHandlerEX(LPNMHDR pnmh)
2144 #define CR_NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \
2145 if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && \
2146 ((LPNMHDR)lParam)->idFrom >= idFirst && \
2147 ((LPNMHDR)lParam)->idFrom <= idLast) { \
2148 SetMsgHandled(TRUE); \
2149 lResult = func((LPNMHDR)lParam); \
2150 if (IsMsgHandled()) \
2151 return TRUE; \
2154 // LRESULT OnReflectedCommandHandlerEX(UINT uNotifyCode, int nID, CWindow
2155 // wndCtl)
2156 #define CR_REFLECTED_COMMAND_HANDLER_EX(id, code, func) \
2157 if (uMsg == OCM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) { \
2158 SetMsgHandled(TRUE); \
2159 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2160 lResult = 0; \
2161 if (IsMsgHandled()) \
2162 return TRUE; \
2165 // LRESULT OnReflectedCommandIDHandlerEX(UINT uNotifyCode, int nID, CWindow
2166 // wndCtl)
2167 #define CR_REFLECTED_COMMAND_ID_HANDLER_EX(id, func) \
2168 if (uMsg == OCM_COMMAND && id == LOWORD(wParam)) { \
2169 SetMsgHandled(TRUE); \
2170 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2171 lResult = 0; \
2172 if (IsMsgHandled()) \
2173 return TRUE; \
2176 // LRESULT OnReflectedCommandCodeHandlerEX(UINT uNotifyCode, int nID, CWindow
2177 // wndCtl)
2178 #define CR_REFLECTED_COMMAND_CODE_HANDLER_EX(code, func) \
2179 if (uMsg == OCM_COMMAND && code == HIWORD(wParam)) { \
2180 SetMsgHandled(TRUE); \
2181 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2182 lResult = 0; \
2183 if (IsMsgHandled()) \
2184 return TRUE; \
2187 // LRESULT OnReflectedNotifyHandlerEX(LPNMHDR pnmh)
2188 #define CR_REFLECTED_NOTIFY_HANDLER_EX(id, cd, func) \
2189 if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && \
2190 id == ((LPNMHDR)lParam)->idFrom) { \
2191 SetMsgHandled(TRUE); \
2192 lResult = func((LPNMHDR)lParam); \
2193 if (IsMsgHandled()) \
2194 return TRUE; \
2197 // LRESULT OnReflectedNotifyIDHandlerEX(LPNMHDR pnmh)
2198 #define CR_REFLECTED_NOTIFY_ID_HANDLER_EX(id, func) \
2199 if (uMsg == OCM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) { \
2200 SetMsgHandled(TRUE); \
2201 lResult = func((LPNMHDR)lParam); \
2202 if (IsMsgHandled()) \
2203 return TRUE; \
2206 // LRESULT OnReflectedNotifyCodeHandlerEX(LPNMHDR pnmh)
2207 #define CR_REFLECTED_NOTIFY_CODE_HANDLER_EX(cd, func) \
2208 if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code) { \
2209 SetMsgHandled(TRUE); \
2210 lResult = func((LPNMHDR)lParam); \
2211 if (IsMsgHandled()) \
2212 return TRUE; \
2215 // void OnReflectedCommandRangeHandlerEX(UINT uNotifyCode, int nID, CWindow
2216 // wndCtl)
2217 #define CR_REFLECTED_COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \
2218 if (uMsg == OCM_COMMAND && LOWORD(wParam) >= idFirst && \
2219 LOWORD(wParam) <= idLast) { \
2220 SetMsgHandled(TRUE); \
2221 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2222 lResult = 0; \
2223 if (IsMsgHandled()) \
2224 return TRUE; \
2227 // void OnReflectedCommandRangeCodeHandlerEX(UINT uNotifyCode, int nID, CWindow
2228 // wndCtl)
2229 #define CR_REFLECTED_COMMAND_RANGE_CODE_HANDLER_EX( \
2230 idFirst, idLast, code, func) \
2231 if (uMsg == OCM_COMMAND && code == HIWORD(wParam) && \
2232 LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) { \
2233 SetMsgHandled(TRUE); \
2234 func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
2235 lResult = 0; \
2236 if (IsMsgHandled()) \
2237 return TRUE; \
2240 // LRESULT OnReflectedNotifyRangeHandlerEX(LPNMHDR pnmh)
2241 #define CR_REFLECTED_NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \
2242 if (uMsg == OCM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && \
2243 ((LPNMHDR)lParam)->idFrom <= idLast) { \
2244 SetMsgHandled(TRUE); \
2245 lResult = func((LPNMHDR)lParam); \
2246 if (IsMsgHandled()) \
2247 return TRUE; \
2250 // LRESULT OnReflectedNotifyRangeCodeHandlerEX(LPNMHDR pnmh)
2251 #define CR_REFLECTED_NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \
2252 if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && \
2253 ((LPNMHDR)lParam)->idFrom >= idFirst && \
2254 ((LPNMHDR)lParam)->idFrom <= idLast) { \
2255 SetMsgHandled(TRUE); \
2256 lResult = func((LPNMHDR)lParam); \
2257 if (IsMsgHandled()) \
2258 return TRUE; \
2261 #define CR_DEFLATE_RECT(rect, by) \
2263 (rect)->left += (by)->left; \
2264 (rect)->top += (by)->top; \
2265 (rect)->right -= (by)->right; \
2266 (rect)->bottom -= (by)->bottom; \
2269 #define CR_POINT_INITIALIZER_FROM_LPARAM(lparam) \
2270 { LOWORD(lparam), HIWORD(lparam) }
2272 #endif // UI_GFX_WIN_MSG_UTIL_H_