yum-archive/TaSTT-Whisper

High-performance GPGPU inference of OpenAI's Whisper automatic speech recognition (ASR) model

git clone https://git.yummers.dev/yum-archive/TaSTT-Whisper

KonstantinSource codes8c4603c

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