Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1909 lines
47 KiB

  1. // WTL Version 3.1
  2. // Copyright (C) 1997-2000 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This file is a part of Windows Template Library.
  6. // The code and information is provided "as-is" without
  7. // warranty of any kind, either expressed or implied.
  8. #ifndef __ATLCRACK_H__
  9. #define __ATLCRACK_H__
  10. #pragma once
  11. // For ATL 3.0, message map using cracked handlers MUST use BEGIN_MSG_MAP_EX
  12. #if !defined(_ATL_TMP_IMPL1) && !defined(_ATL_TMP_IMPL2)
  13. #define BEGIN_MSG_MAP_EX(theClass) \
  14. public: \
  15. BOOL m_bATL3MsgHandled; \
  16. /* "handled" management for cracked handlers */ \
  17. BOOL IsMsgHandled() const \
  18. { \
  19. return m_bATL3MsgHandled; \
  20. } \
  21. void SetMsgHandled(BOOL bHandled) \
  22. { \
  23. m_bATL3MsgHandled = bHandled; \
  24. } \
  25. BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0) \
  26. { \
  27. BOOL bATL3OldMsgHandled = m_bATL3MsgHandled; \
  28. BOOL bRet = _ProcessWindowMessage(hWnd, uMsg, wParam, lParam, lResult, dwMsgMapID); \
  29. m_bATL3MsgHandled = bATL3OldMsgHandled; \
  30. return bRet; \
  31. } \
  32. BOOL _ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID) \
  33. { \
  34. BOOL bHandled = TRUE; \
  35. hWnd; \
  36. uMsg; \
  37. wParam; \
  38. lParam; \
  39. lResult; \
  40. bHandled; \
  41. switch(dwMsgMapID) \
  42. { \
  43. case 0:
  44. #endif //!defined(_ATL_TMP_IMPL1) && !defined(_ATL_TMP_IMPL2)
  45. ///////////////////////////////////////////////////////////////////////////////
  46. // Standard Windows message macros
  47. #define MSG_WM_CREATE(func) \
  48. if (uMsg == WM_CREATE) \
  49. { \
  50. SetMsgHandled(TRUE); \
  51. lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \
  52. if(IsMsgHandled()) \
  53. return TRUE; \
  54. }
  55. #define MSG_WM_INITDIALOG(func) \
  56. if (uMsg == WM_INITDIALOG) \
  57. { \
  58. SetMsgHandled(TRUE); \
  59. lResult = (LRESULT)func((HWND)wParam, lParam); \
  60. if(IsMsgHandled()) \
  61. return TRUE; \
  62. }
  63. #define MSG_WM_COPYDATA(func) \
  64. if (uMsg == WM_COPYDATA) \
  65. { \
  66. SetMsgHandled(TRUE); \
  67. lResult = (LRESULT)func((HWND)wParam, (PCOPYDATASTRUCT)lParam); \
  68. if(IsMsgHandled()) \
  69. return TRUE; \
  70. }
  71. #define MSG_WM_DESTROY(func) \
  72. if (uMsg == WM_DESTROY) \
  73. { \
  74. SetMsgHandled(TRUE); \
  75. func(); \
  76. lResult = 0; \
  77. if(IsMsgHandled()) \
  78. return TRUE; \
  79. }
  80. #define MSG_WM_MOVE(func) \
  81. if (uMsg == WM_MOVE) \
  82. { \
  83. SetMsgHandled(TRUE); \
  84. func(CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  85. lResult = 0; \
  86. if(IsMsgHandled()) \
  87. return TRUE; \
  88. }
  89. #define MSG_WM_SIZE(func) \
  90. if (uMsg == WM_SIZE) \
  91. { \
  92. SetMsgHandled(TRUE); \
  93. func((UINT)wParam, CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  94. lResult = 0; \
  95. if(IsMsgHandled()) \
  96. return TRUE; \
  97. }
  98. #define MSG_WM_ACTIVATE(func) \
  99. if (uMsg == WM_ACTIVATE) \
  100. { \
  101. SetMsgHandled(TRUE); \
  102. func((UINT)LOWORD(wParam), (BOOL)HIWORD(wParam), (HWND)lParam); \
  103. lResult = 0; \
  104. if(IsMsgHandled()) \
  105. return TRUE; \
  106. }
  107. #define MSG_WM_SETFOCUS(func) \
  108. if (uMsg == WM_SETFOCUS) \
  109. { \
  110. SetMsgHandled(TRUE); \
  111. func((HWND)wParam); \
  112. lResult = 0; \
  113. if(IsMsgHandled()) \
  114. return TRUE; \
  115. }
  116. #define MSG_WM_KILLFOCUS(func) \
  117. if (uMsg == WM_KILLFOCUS) \
  118. { \
  119. SetMsgHandled(TRUE); \
  120. func((HWND)wParam); \
  121. lResult = 0; \
  122. if(IsMsgHandled()) \
  123. return TRUE; \
  124. }
  125. #define MSG_WM_ENABLE(func) \
  126. if (uMsg == WM_ENABLE) \
  127. { \
  128. SetMsgHandled(TRUE); \
  129. func((BOOL)wParam); \
  130. lResult = 0; \
  131. if(IsMsgHandled()) \
  132. return TRUE; \
  133. }
  134. #define MSG_WM_PAINT(func) \
  135. if (uMsg == WM_PAINT) \
  136. { \
  137. SetMsgHandled(TRUE); \
  138. func((HDC)wParam); \
  139. lResult = 0; \
  140. if(IsMsgHandled()) \
  141. return TRUE; \
  142. }
  143. #define MSG_WM_CLOSE(func) \
  144. if (uMsg == WM_CLOSE) \
  145. { \
  146. SetMsgHandled(TRUE); \
  147. func(); \
  148. lResult = 0; \
  149. if(IsMsgHandled()) \
  150. return TRUE; \
  151. }
  152. #define MSG_WM_QUERYENDSESSION(func) \
  153. if (uMsg == WM_QUERYENDSESSION) \
  154. { \
  155. SetMsgHandled(TRUE); \
  156. lResult = (LRESULT)func((UINT)wParam, (UINT)lParam); \
  157. if(IsMsgHandled()) \
  158. return TRUE; \
  159. }
  160. #define MSG_WM_QUERYOPEN(func) \
  161. if (uMsg == WM_QUERYOPEN) \
  162. { \
  163. SetMsgHandled(TRUE); \
  164. lResult = (LRESULT)func(); \
  165. if(IsMsgHandled()) \
  166. return TRUE; \
  167. }
  168. #define MSG_WM_ERASEBKGND(func) \
  169. if (uMsg == WM_ERASEBKGND) \
  170. { \
  171. SetMsgHandled(TRUE); \
  172. lResult = (LRESULT)func((HDC)wParam); \
  173. if(IsMsgHandled()) \
  174. return TRUE; \
  175. }
  176. #define MSG_WM_SYSCOLORCHANGE(func) \
  177. if (uMsg == WM_SYSCOLORCHANGE) \
  178. { \
  179. SetMsgHandled(TRUE); \
  180. func(); \
  181. lResult = 0; \
  182. if(IsMsgHandled()) \
  183. return TRUE; \
  184. }
  185. #define MSG_WM_ENDSESSION(func) \
  186. if (uMsg == WM_ENDSESSION) \
  187. { \
  188. SetMsgHandled(TRUE); \
  189. func((BOOL)wParam, (UINT)lParam); \
  190. lResult = 0; \
  191. if(IsMsgHandled()) \
  192. return TRUE; \
  193. }
  194. #define MSG_WM_SHOWWINDOW(func) \
  195. if (uMsg == WM_SHOWWINDOW) \
  196. { \
  197. SetMsgHandled(TRUE); \
  198. func((BOOL)wParam, (int)lParam); \
  199. lResult = 0; \
  200. if(IsMsgHandled()) \
  201. return TRUE; \
  202. }
  203. #define MSG_WM_CTLCOLOREDIT(func) \
  204. if (uMsg == WM_CTLCOLOREDIT) \
  205. { \
  206. SetMsgHandled(TRUE); \
  207. lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
  208. if(IsMsgHandled()) \
  209. return TRUE; \
  210. }
  211. #define MSG_WM_CTLCOLORLISTBOX(func) \
  212. if (uMsg == WM_CTLCOLORLISTBOX) \
  213. { \
  214. SetMsgHandled(TRUE); \
  215. lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
  216. if(IsMsgHandled()) \
  217. return TRUE; \
  218. }
  219. #define MSG_WM_CTLCOLORBTN(func) \
  220. if (uMsg == WM_CTLCOLORBTN) \
  221. { \
  222. SetMsgHandled(TRUE); \
  223. lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
  224. if(IsMsgHandled()) \
  225. return TRUE; \
  226. }
  227. #define MSG_WM_CTLCOLORDLG(func) \
  228. if (uMsg == WM_CTLCOLORDLG) \
  229. { \
  230. SetMsgHandled(TRUE); \
  231. lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
  232. if(IsMsgHandled()) \
  233. return TRUE; \
  234. }
  235. #define MSG_WM_CTLCOLORSCROLLBAR(func) \
  236. if (uMsg == WM_CTLCOLORSCROLLBAR) \
  237. { \
  238. SetMsgHandled(TRUE); \
  239. lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
  240. if(IsMsgHandled()) \
  241. return TRUE; \
  242. }
  243. #define MSG_WM_CTLCOLORSTATIC(func) \
  244. if (uMsg == WM_CTLCOLORSTATIC) \
  245. { \
  246. SetMsgHandled(TRUE); \
  247. lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
  248. if(IsMsgHandled()) \
  249. return TRUE; \
  250. }
  251. #define MSG_WM_SETTINGCHANGE(func) \
  252. if (uMsg == WM_SETTINGCHANGE) \
  253. { \
  254. SetMsgHandled(TRUE); \
  255. func((UINT)wParam, (LPCTSTR)lParam); \
  256. lResult = 0; \
  257. if(IsMsgHandled()) \
  258. return TRUE; \
  259. }
  260. #define MSG_WM_DEVMODECHANGE(func) \
  261. if (uMsg == WM_DEVMODECHANGE) \
  262. { \
  263. SetMsgHandled(TRUE); \
  264. func((LPCTSTR)lParam); \
  265. lResult = 0; \
  266. if(IsMsgHandled()) \
  267. return TRUE; \
  268. }
  269. #define MSG_WM_ACTIVATEAPP(func) \
  270. if (uMsg == WM_ACTIVATEAPP) \
  271. { \
  272. SetMsgHandled(TRUE); \
  273. func((BOOL)wParam, (DWORD)lParam); \
  274. lResult = 0; \
  275. if(IsMsgHandled()) \
  276. return TRUE; \
  277. }
  278. #define MSG_WM_FONTCHANGE(func) \
  279. if (uMsg == WM_FONTCHANGE) \
  280. { \
  281. SetMsgHandled(TRUE); \
  282. func(); \
  283. lResult = 0; \
  284. if(IsMsgHandled()) \
  285. return TRUE; \
  286. }
  287. #define MSG_WM_TIMECHANGE(func) \
  288. if (uMsg == WM_TIMECHANGE) \
  289. { \
  290. SetMsgHandled(TRUE); \
  291. func(); \
  292. lResult = 0; \
  293. if(IsMsgHandled()) \
  294. return TRUE; \
  295. }
  296. #define MSG_WM_CANCELMODE(func) \
  297. if (uMsg == WM_CANCELMODE) \
  298. { \
  299. SetMsgHandled(TRUE); \
  300. func(); \
  301. lResult = 0; \
  302. if(IsMsgHandled()) \
  303. return TRUE; \
  304. }
  305. #define MSG_WM_SETCURSOR(func) \
  306. if (uMsg == WM_SETCURSOR) \
  307. { \
  308. SetMsgHandled(TRUE); \
  309. lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
  310. if(IsMsgHandled()) \
  311. return TRUE; \
  312. }
  313. #define MSG_WM_MOUSEACTIVATE(func) \
  314. if (uMsg == WM_MOUSEACTIVATE) \
  315. { \
  316. SetMsgHandled(TRUE); \
  317. lResult = (LRESULT)func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
  318. if(IsMsgHandled()) \
  319. return TRUE; \
  320. }
  321. #define MSG_WM_CHILDACTIVATE(func) \
  322. if (uMsg == WM_CHILDACTIVATE) \
  323. { \
  324. SetMsgHandled(TRUE); \
  325. func(); \
  326. lResult = 0; \
  327. if(IsMsgHandled()) \
  328. return TRUE; \
  329. }
  330. #define MSG_WM_GETMINMAXINFO(func) \
  331. if (uMsg == WM_GETMINMAXINFO) \
  332. { \
  333. SetMsgHandled(TRUE); \
  334. func((LPMINMAXINFO)lParam); \
  335. lResult = 0; \
  336. if(IsMsgHandled()) \
  337. return TRUE; \
  338. }
  339. #define MSG_WM_ICONERASEBKGND(func) \
  340. if (uMsg == WM_ICONERASEBKGND) \
  341. { \
  342. SetMsgHandled(TRUE); \
  343. func((HDC)wParam); \
  344. lResult = 0; \
  345. if(IsMsgHandled()) \
  346. return TRUE; \
  347. }
  348. #define MSG_WM_SPOOLERSTATUS(func) \
  349. if (uMsg == WM_SPOOLERSTATUS) \
  350. { \
  351. SetMsgHandled(TRUE); \
  352. func((UINT)wParam, (UINT)LOWORD(lParam)); \
  353. lResult = 0; \
  354. if(IsMsgHandled()) \
  355. return TRUE; \
  356. }
  357. #define MSG_WM_DRAWITEM(func) \
  358. if (uMsg == WM_DRAWITEM) \
  359. { \
  360. SetMsgHandled(TRUE); \
  361. func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \
  362. lResult = TRUE; \
  363. if(IsMsgHandled()) \
  364. return TRUE; \
  365. }
  366. #define MSG_WM_MEASUREITEM(func) \
  367. if (uMsg == WM_MEASUREITEM) \
  368. { \
  369. SetMsgHandled(TRUE); \
  370. func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \
  371. lResult = TRUE; \
  372. if(IsMsgHandled()) \
  373. return TRUE; \
  374. }
  375. #define MSG_WM_DELETEITEM(func) \
  376. if (uMsg == WM_DELETEITEM) \
  377. { \
  378. SetMsgHandled(TRUE); \
  379. func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \
  380. lResult = TRUE; \
  381. if(IsMsgHandled()) \
  382. return TRUE; \
  383. }
  384. #define MSG_WM_CHARTOITEM(func) \
  385. if (uMsg == WM_CHARTOITEM) \
  386. { \
  387. SetMsgHandled(TRUE); \
  388. lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
  389. if(IsMsgHandled()) \
  390. return TRUE; \
  391. }
  392. #define MSG_WM_VKEYTOITEM(func) \
  393. if (uMsg == WM_VKEYTOITEM) \
  394. { \
  395. SetMsgHandled(TRUE); \
  396. lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
  397. if(IsMsgHandled()) \
  398. return TRUE; \
  399. }
  400. #define MSG_WM_QUERYDRAGICON(func) \
  401. if (uMsg == WM_QUERYDRAGICON) \
  402. { \
  403. SetMsgHandled(TRUE); \
  404. lResult = (LRESULT)func(); \
  405. if(IsMsgHandled()) \
  406. return TRUE; \
  407. }
  408. #define MSG_WM_COMPAREITEM(func) \
  409. if (uMsg == WM_COMPAREITEM) \
  410. { \
  411. SetMsgHandled(TRUE); \
  412. lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \
  413. if(IsMsgHandled()) \
  414. return TRUE; \
  415. }
  416. #define MSG_WM_COMPACTING(func) \
  417. if (uMsg == WM_COMPACTING) \
  418. { \
  419. SetMsgHandled(TRUE); \
  420. func((UINT)wParam); \
  421. lResult = 0; \
  422. if(IsMsgHandled()) \
  423. return TRUE; \
  424. }
  425. #define MSG_WM_NCCREATE(func) \
  426. if (uMsg == WM_NCCREATE) \
  427. { \
  428. SetMsgHandled(TRUE); \
  429. lResult = (LRESULT)func((LPCREATESTRUCT)lParam); \
  430. if(IsMsgHandled()) \
  431. return TRUE; \
  432. }
  433. #define MSG_WM_NCDESTROY(func) \
  434. if (uMsg == WM_NCDESTROY) \
  435. { \
  436. SetMsgHandled(TRUE); \
  437. func(); \
  438. lResult = 0; \
  439. if(IsMsgHandled()) \
  440. return TRUE; \
  441. }
  442. #define MSG_WM_NCCALCSIZE(func) \
  443. if (uMsg == WM_NCCALCSIZE) \
  444. { \
  445. SetMsgHandled(TRUE); \
  446. lResult = func((BOOL)wParam, lParam); \
  447. if(IsMsgHandled()) \
  448. return TRUE; \
  449. }
  450. #define MSG_WM_NCHITTEST(func) \
  451. if (uMsg == WM_NCHITTEST) \
  452. { \
  453. SetMsgHandled(TRUE); \
  454. lResult = (LRESULT)func(CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  455. if(IsMsgHandled()) \
  456. return TRUE; \
  457. }
  458. #define MSG_WM_NCPAINT(func) \
  459. if (uMsg == WM_NCPAINT) \
  460. { \
  461. SetMsgHandled(TRUE); \
  462. func((HRGN)wParam); \
  463. lResult = 0; \
  464. if(IsMsgHandled()) \
  465. return TRUE; \
  466. }
  467. #define MSG_WM_NCACTIVATE(func) \
  468. if (uMsg == WM_NCACTIVATE) \
  469. { \
  470. SetMsgHandled(TRUE); \
  471. lResult = (LRESULT)func((BOOL)wParam); \
  472. if(IsMsgHandled()) \
  473. return TRUE; \
  474. }
  475. #define MSG_WM_GETDLGCODE(func) \
  476. if (uMsg == WM_GETDLGCODE) \
  477. { \
  478. SetMsgHandled(TRUE); \
  479. lResult = (LRESULT)func((LPMSG)lParam); \
  480. if(IsMsgHandled()) \
  481. return TRUE; \
  482. }
  483. #define MSG_WM_NCMOUSEMOVE(func) \
  484. if (uMsg == WM_NCMOUSEMOVE) \
  485. { \
  486. SetMsgHandled(TRUE); \
  487. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  488. lResult = 0; \
  489. if(IsMsgHandled()) \
  490. return TRUE; \
  491. }
  492. #define MSG_WM_NCLBUTTONDOWN(func) \
  493. if (uMsg == WM_NCLBUTTONDOWN) \
  494. { \
  495. SetMsgHandled(TRUE); \
  496. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  497. lResult = 0; \
  498. if(IsMsgHandled()) \
  499. return TRUE; \
  500. }
  501. #define MSG_WM_NCLBUTTONUP(func) \
  502. if (uMsg == WM_NCLBUTTONUP) \
  503. { \
  504. SetMsgHandled(TRUE); \
  505. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  506. lResult = 0; \
  507. if(IsMsgHandled()) \
  508. return TRUE; \
  509. }
  510. #define MSG_WM_NCLBUTTONDBLCLK(func) \
  511. if (uMsg == WM_NCLBUTTONDBLCLK) \
  512. { \
  513. SetMsgHandled(TRUE); \
  514. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  515. lResult = 0; \
  516. if(IsMsgHandled()) \
  517. return TRUE; \
  518. }
  519. #define MSG_WM_NCRBUTTONDOWN(func) \
  520. if (uMsg == WM_NCRBUTTONDOWN) \
  521. { \
  522. SetMsgHandled(TRUE); \
  523. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  524. lResult = 0; \
  525. if(IsMsgHandled()) \
  526. return TRUE; \
  527. }
  528. #define MSG_WM_NCRBUTTONUP(func) \
  529. if (uMsg == WM_NCRBUTTONUP) \
  530. { \
  531. SetMsgHandled(TRUE); \
  532. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  533. lResult = 0; \
  534. if(IsMsgHandled()) \
  535. return TRUE; \
  536. }
  537. #define MSG_WM_NCRBUTTONDBLCLK(func) \
  538. if (uMsg == WM_NCRBUTTONDBLCLK) \
  539. { \
  540. SetMsgHandled(TRUE); \
  541. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  542. lResult = 0; \
  543. if(IsMsgHandled()) \
  544. return TRUE; \
  545. }
  546. #define MSG_WM_NCMBUTTONDOWN(func) \
  547. if (uMsg == WM_NCMBUTTONDOWN) \
  548. { \
  549. SetMsgHandled(TRUE); \
  550. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  551. lResult = 0; \
  552. if(IsMsgHandled()) \
  553. return TRUE; \
  554. }
  555. #define MSG_WM_NCMBUTTONUP(func) \
  556. if (uMsg == WM_NCMBUTTONUP) \
  557. { \
  558. SetMsgHandled(TRUE); \
  559. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  560. lResult = 0; \
  561. if(IsMsgHandled()) \
  562. return TRUE; \
  563. }
  564. #define MSG_WM_NCMBUTTONDBLCLK(func) \
  565. if (uMsg == WM_NCMBUTTONDBLCLK) \
  566. { \
  567. SetMsgHandled(TRUE); \
  568. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  569. lResult = 0; \
  570. if(IsMsgHandled()) \
  571. return TRUE; \
  572. }
  573. #define MSG_WM_KEYDOWN(func) \
  574. if (uMsg == WM_KEYDOWN) \
  575. { \
  576. SetMsgHandled(TRUE); \
  577. func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
  578. lResult = 0; \
  579. if(IsMsgHandled()) \
  580. return TRUE; \
  581. }
  582. #define MSG_WM_KEYUP(func) \
  583. if (uMsg == WM_KEYUP) \
  584. { \
  585. SetMsgHandled(TRUE); \
  586. func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
  587. lResult = 0; \
  588. if(IsMsgHandled()) \
  589. return TRUE; \
  590. }
  591. #define MSG_WM_CHAR(func) \
  592. if (uMsg == WM_CHAR) \
  593. { \
  594. SetMsgHandled(TRUE); \
  595. func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
  596. lResult = 0; \
  597. if(IsMsgHandled()) \
  598. return TRUE; \
  599. }
  600. #define MSG_WM_DEADCHAR(func) \
  601. if (uMsg == WM_DEADCHAR) \
  602. { \
  603. SetMsgHandled(TRUE); \
  604. func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
  605. lResult = 0; \
  606. if(IsMsgHandled()) \
  607. return TRUE; \
  608. }
  609. #define MSG_WM_SYSKEYDOWN(func) \
  610. if (uMsg == WM_SYSKEYDOWN) \
  611. { \
  612. SetMsgHandled(TRUE); \
  613. func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
  614. lResult = 0; \
  615. if(IsMsgHandled()) \
  616. return TRUE; \
  617. }
  618. #define MSG_WM_SYSKEYUP(func) \
  619. if (uMsg == WM_SYSKEYUP) \
  620. { \
  621. SetMsgHandled(TRUE); \
  622. func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
  623. lResult = 0; \
  624. if(IsMsgHandled()) \
  625. return TRUE; \
  626. }
  627. #define MSG_WM_SYSCHAR(func) \
  628. if (uMsg == WM_SYSCHAR) \
  629. { \
  630. SetMsgHandled(TRUE); \
  631. func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
  632. lResult = 0; \
  633. if(IsMsgHandled()) \
  634. return TRUE; \
  635. }
  636. #define MSG_WM_SYSDEADCHAR(func) \
  637. if (uMsg == WM_SYSDEADCHAR) \
  638. { \
  639. SetMsgHandled(TRUE); \
  640. func((TCHAR)wParam, (UINT)lParam & 0xFFFF, (UINT)((lParam & 0xFFFF0000) >> 16)); \
  641. lResult = 0; \
  642. if(IsMsgHandled()) \
  643. return TRUE; \
  644. }
  645. #define MSG_WM_SYSCOMMAND(func) \
  646. if (uMsg == WM_SYSCOMMAND) \
  647. { \
  648. SetMsgHandled(TRUE); \
  649. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  650. lResult = 0; \
  651. if(IsMsgHandled()) \
  652. return TRUE; \
  653. }
  654. #define MSG_WM_TCARD(func) \
  655. if (uMsg == WM_TCARD) \
  656. { \
  657. SetMsgHandled(TRUE); \
  658. func((UINT)wParam, (DWORD)lParam); \
  659. lResult = 0; \
  660. if(IsMsgHandled()) \
  661. return TRUE; \
  662. }
  663. #define MSG_WM_TIMER(func) \
  664. if (uMsg == WM_TIMER) \
  665. { \
  666. SetMsgHandled(TRUE); \
  667. func((UINT)wParam, (TIMERPROC*)lParam); \
  668. lResult = 0; \
  669. if(IsMsgHandled()) \
  670. return TRUE; \
  671. }
  672. #define MSG_WM_HSCROLL(func) \
  673. if (uMsg == WM_HSCROLL) \
  674. { \
  675. SetMsgHandled(TRUE); \
  676. func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
  677. lResult = 0; \
  678. if(IsMsgHandled()) \
  679. return TRUE; \
  680. }
  681. #define MSG_WM_VSCROLL(func) \
  682. if (uMsg == WM_VSCROLL) \
  683. { \
  684. SetMsgHandled(TRUE); \
  685. func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
  686. lResult = 0; \
  687. if(IsMsgHandled()) \
  688. return TRUE; \
  689. }
  690. #define MSG_WM_INITMENU(func) \
  691. if (uMsg == WM_INITMENU) \
  692. { \
  693. SetMsgHandled(TRUE); \
  694. func((HMENU)wParam); \
  695. lResult = 0; \
  696. if(IsMsgHandled()) \
  697. return TRUE; \
  698. }
  699. #define MSG_WM_INITMENUPOPUP(func) \
  700. if (uMsg == WM_INITMENUPOPUP) \
  701. { \
  702. SetMsgHandled(TRUE); \
  703. func((HMENU)wParam, (UINT)LOWORD(lParam), (BOOL)HIWORD(lParam)); \
  704. lResult = 0; \
  705. if(IsMsgHandled()) \
  706. return TRUE; \
  707. }
  708. #define MSG_WM_MENUSELECT(func) \
  709. if (uMsg == WM_MENUSELECT) \
  710. { \
  711. SetMsgHandled(TRUE); \
  712. func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \
  713. lResult = 0; \
  714. if(IsMsgHandled()) \
  715. return TRUE; \
  716. }
  717. #define MSG_WM_MENUCHAR(func) \
  718. if (uMsg == WM_MENUCHAR) \
  719. { \
  720. SetMsgHandled(TRUE); \
  721. lResult = func((TCHAR)LOWORD(wParam), (UINT)HIWORD(wParam), (HMENU)lParam); \
  722. if(IsMsgHandled()) \
  723. return TRUE; \
  724. }
  725. #define MSG_WM_NOTIFY(func) \
  726. if (uMsg == WM_NOTIFY) \
  727. { \
  728. SetMsgHandled(TRUE); \
  729. lResult = func((int)wParam, (LPNMHDR)lParam); \
  730. if(IsMsgHandled()) \
  731. return TRUE; \
  732. }
  733. #define MSG_WM_ENTERIDLE(func) \
  734. if (uMsg == WM_ENTERIDLE) \
  735. { \
  736. SetMsgHandled(TRUE); \
  737. func((UINT)wParam, (HWND)lParam); \
  738. lResult = 0; \
  739. if(IsMsgHandled()) \
  740. return TRUE; \
  741. }
  742. #define MSG_WM_MOUSEMOVE(func) \
  743. if (uMsg == WM_MOUSEMOVE) \
  744. { \
  745. SetMsgHandled(TRUE); \
  746. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  747. lResult = 0; \
  748. if(IsMsgHandled()) \
  749. return TRUE; \
  750. }
  751. #define MSG_WM_MOUSEWHEEL(func) \
  752. if (uMsg == WM_MOUSEWHEEL) \
  753. { \
  754. SetMsgHandled(TRUE); \
  755. lResult = (LRESULT)func((UINT)LOWORD(wParam), (short)HIWORD(wParam), CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  756. if(IsMsgHandled()) \
  757. return TRUE; \
  758. }
  759. #define MSG_WM_LBUTTONDOWN(func) \
  760. if (uMsg == WM_LBUTTONDOWN) \
  761. { \
  762. SetMsgHandled(TRUE); \
  763. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  764. lResult = 0; \
  765. if(IsMsgHandled()) \
  766. return TRUE; \
  767. }
  768. #define MSG_WM_LBUTTONUP(func) \
  769. if (uMsg == WM_LBUTTONUP) \
  770. { \
  771. SetMsgHandled(TRUE); \
  772. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  773. lResult = 0; \
  774. if(IsMsgHandled()) \
  775. return TRUE; \
  776. }
  777. #define MSG_WM_LBUTTONDBLCLK(func) \
  778. if (uMsg == WM_LBUTTONDBLCLK) \
  779. { \
  780. SetMsgHandled(TRUE); \
  781. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  782. lResult = 0; \
  783. if(IsMsgHandled()) \
  784. return TRUE; \
  785. }
  786. #define MSG_WM_RBUTTONDOWN(func) \
  787. if (uMsg == WM_RBUTTONDOWN) \
  788. { \
  789. SetMsgHandled(TRUE); \
  790. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  791. lResult = 0; \
  792. if(IsMsgHandled()) \
  793. return TRUE; \
  794. }
  795. #define MSG_WM_RBUTTONUP(func) \
  796. if (uMsg == WM_RBUTTONUP) \
  797. { \
  798. SetMsgHandled(TRUE); \
  799. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  800. lResult = 0; \
  801. if(IsMsgHandled()) \
  802. return TRUE; \
  803. }
  804. #define MSG_WM_RBUTTONDBLCLK(func) \
  805. if (uMsg == WM_RBUTTONDBLCLK) \
  806. { \
  807. SetMsgHandled(TRUE); \
  808. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  809. lResult = 0; \
  810. if(IsMsgHandled()) \
  811. return TRUE; \
  812. }
  813. #define MSG_WM_MBUTTONDOWN(func) \
  814. if (uMsg == WM_MBUTTONDOWN) \
  815. { \
  816. SetMsgHandled(TRUE); \
  817. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  818. lResult = 0; \
  819. if(IsMsgHandled()) \
  820. return TRUE; \
  821. }
  822. #define MSG_WM_MBUTTONUP(func) \
  823. if (uMsg == WM_MBUTTONUP) \
  824. { \
  825. SetMsgHandled(TRUE); \
  826. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  827. lResult = 0; \
  828. if(IsMsgHandled()) \
  829. return TRUE; \
  830. }
  831. #define MSG_WM_MBUTTONDBLCLK(func) \
  832. if (uMsg == WM_MBUTTONDBLCLK) \
  833. { \
  834. SetMsgHandled(TRUE); \
  835. func((UINT)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  836. lResult = 0; \
  837. if(IsMsgHandled()) \
  838. return TRUE; \
  839. }
  840. #define MSG_WM_PARENTNOTIFY(func) \
  841. if (uMsg == WM_PARENTNOTIFY) \
  842. { \
  843. SetMsgHandled(TRUE); \
  844. func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \
  845. lResult = 0; \
  846. if(IsMsgHandled()) \
  847. return TRUE; \
  848. }
  849. #define MSG_WM_MDIACTIVATE(func) \
  850. if (uMsg == WM_MDIACTIVATE) \
  851. { \
  852. SetMsgHandled(TRUE); \
  853. func((HWND)wParam, (HWND)lParam); \
  854. lResult = 0; \
  855. if(IsMsgHandled()) \
  856. return TRUE; \
  857. }
  858. #define MSG_WM_RENDERFORMAT(func) \
  859. if (uMsg == WM_RENDERFORMAT) \
  860. { \
  861. SetMsgHandled(TRUE); \
  862. func((UINT)wParam); \
  863. lResult = 0; \
  864. if(IsMsgHandled()) \
  865. return TRUE; \
  866. }
  867. #define MSG_WM_RENDERALLFORMATS(func) \
  868. if (uMsg == WM_RENDERALLFORMATS) \
  869. { \
  870. SetMsgHandled(TRUE); \
  871. func(); \
  872. lResult = 0; \
  873. if(IsMsgHandled()) \
  874. return TRUE; \
  875. }
  876. #define MSG_WM_DESTROYCLIPBOARD(func) \
  877. if (uMsg == WM_DESTROYCLIPBOARD) \
  878. { \
  879. SetMsgHandled(TRUE); \
  880. func(); \
  881. lResult = 0; \
  882. if(IsMsgHandled()) \
  883. return TRUE; \
  884. }
  885. #define MSG_WM_DRAWCLIPBOARD(func) \
  886. if (uMsg == WM_DRAWCLIPBOARD) \
  887. { \
  888. SetMsgHandled(TRUE); \
  889. func(); \
  890. lResult = 0; \
  891. if(IsMsgHandled()) \
  892. return TRUE; \
  893. }
  894. #define MSG_WM_PAINTCLIPBOARD(func) \
  895. if (uMsg == WM_PAINTCLIPBOARD) \
  896. { \
  897. SetMsgHandled(TRUE); \
  898. func((HWND)wParam, (const LPPAINTSTRUCT)::GlobalLock((HGLOBAL)lParam)); \
  899. ::GlobalUnlock((HGLOBAL)lParam); \
  900. lResult = 0; \
  901. if(IsMsgHandled()) \
  902. return TRUE; \
  903. }
  904. #define MSG_WM_VSCROLLCLIPBOARD(func) \
  905. if (uMsg == WM_VSCROLLCLIPBOARD) \
  906. { \
  907. SetMsgHandled(TRUE); \
  908. func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
  909. lResult = 0; \
  910. if(IsMsgHandled()) \
  911. return TRUE; \
  912. }
  913. #define MSG_WM_CONTEXTMENU(func) \
  914. if (uMsg == WM_CONTEXTMENU) \
  915. { \
  916. SetMsgHandled(TRUE); \
  917. func((HWND)wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  918. lResult = 0; \
  919. if(IsMsgHandled()) \
  920. return TRUE; \
  921. }
  922. #define MSG_WM_SIZECLIPBOARD(func) \
  923. if (uMsg == WM_SIZECLIPBOARD) \
  924. { \
  925. SetMsgHandled(TRUE); \
  926. func((HWND)wParam, (const LPRECT)::GlobalLock((HGLOBAL)lParam)); \
  927. ::GlobalUnlock((HGLOBAL)lParam); \
  928. lResult = 0; \
  929. if(IsMsgHandled()) \
  930. return TRUE; \
  931. }
  932. #define MSG_WM_ASKCBFORMATNAME(func) \
  933. if (uMsg == WM_ASKCBFORMATNAME) \
  934. { \
  935. SetMsgHandled(TRUE); \
  936. func((DWORD)wParam, (LPTSTR)lParam); \
  937. lResult = 0; \
  938. if(IsMsgHandled()) \
  939. return TRUE; \
  940. }
  941. #define MSG_WM_CHANGECBCHAIN(func) \
  942. if (uMsg == WM_CHANGECBCHAIN) \
  943. { \
  944. SetMsgHandled(TRUE); \
  945. func((HWND)wParam, (HWND)lParam); \
  946. lResult = 0; \
  947. if(IsMsgHandled()) \
  948. return TRUE; \
  949. }
  950. #define MSG_WM_HSCROLLCLIPBOARD(func) \
  951. if (uMsg == WM_HSCROLLCLIPBOARD) \
  952. { \
  953. SetMsgHandled(TRUE); \
  954. func((HWND)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
  955. lResult = 0; \
  956. if(IsMsgHandled()) \
  957. return TRUE; \
  958. }
  959. #define MSG_WM_QUERYNEWPALETTE(func) \
  960. if (uMsg == WM_QUERYNEWPALETTE) \
  961. { \
  962. SetMsgHandled(TRUE); \
  963. lResult = (LRESULT)func(); \
  964. if(IsMsgHandled()) \
  965. return TRUE; \
  966. }
  967. #define MSG_WM_PALETTECHANGED(func) \
  968. if (uMsg == WM_PALETTECHANGED) \
  969. { \
  970. SetMsgHandled(TRUE); \
  971. func((HWND)wParam); \
  972. lResult = 0; \
  973. if(IsMsgHandled()) \
  974. return TRUE; \
  975. }
  976. #define MSG_WM_PALETTEISCHANGING(func) \
  977. if (uMsg == WM_PALETTEISCHANGING) \
  978. { \
  979. SetMsgHandled(TRUE); \
  980. func((HWND)wParam); \
  981. lResult = 0; \
  982. if(IsMsgHandled()) \
  983. return TRUE; \
  984. }
  985. #define MSG_WM_DROPFILES(func) \
  986. if (uMsg == WM_DROPFILES) \
  987. { \
  988. SetMsgHandled(TRUE); \
  989. func((HDROP)wParam); \
  990. lResult = 0; \
  991. if(IsMsgHandled()) \
  992. return TRUE; \
  993. }
  994. #define MSG_WM_WINDOWPOSCHANGING(func) \
  995. if (uMsg == WM_WINDOWPOSCHANGING) \
  996. { \
  997. SetMsgHandled(TRUE); \
  998. func((LPWINDOWPOS)lParam); \
  999. lResult = 0; \
  1000. if(IsMsgHandled()) \
  1001. return TRUE; \
  1002. }
  1003. #define MSG_WM_WINDOWPOSCHANGED(func) \
  1004. if (uMsg == WM_WINDOWPOSCHANGED) \
  1005. { \
  1006. SetMsgHandled(TRUE); \
  1007. func((LPWINDOWPOS)lParam); \
  1008. lResult = 0; \
  1009. if(IsMsgHandled()) \
  1010. return TRUE; \
  1011. }
  1012. #define MSG_WM_EXITMENULOOP(func) \
  1013. if (uMsg == WM_EXITMENULOOP) \
  1014. { \
  1015. SetMsgHandled(TRUE); \
  1016. func((BOOL)wParam); \
  1017. lResult = 0; \
  1018. if(IsMsgHandled()) \
  1019. return TRUE; \
  1020. }
  1021. #define MSG_WM_ENTERMENULOOP(func) \
  1022. if (uMsg == WM_ENTERMENULOOP) \
  1023. { \
  1024. SetMsgHandled(TRUE); \
  1025. func((BOOL)wParam); \
  1026. lResult = 0; \
  1027. if(IsMsgHandled()) \
  1028. return TRUE; \
  1029. }
  1030. #define MSG_WM_STYLECHANGED(func) \
  1031. if (uMsg == WM_STYLECHANGED) \
  1032. { \
  1033. SetMsgHandled(TRUE); \
  1034. func((UINT)wParam, (LPSTYLESTRUCT)lParam); \
  1035. lResult = 0; \
  1036. if(IsMsgHandled()) \
  1037. return TRUE; \
  1038. }
  1039. #define MSG_WM_STYLECHANGING(func) \
  1040. if (uMsg == WM_STYLECHANGING) \
  1041. { \
  1042. SetMsgHandled(TRUE); \
  1043. func((UINT)wParam, (LPSTYLESTRUCT)lParam); \
  1044. lResult = 0; \
  1045. if(IsMsgHandled()) \
  1046. return TRUE; \
  1047. }
  1048. #define MSG_WM_SIZING(func) \
  1049. if (uMsg == WM_SIZING) \
  1050. { \
  1051. SetMsgHandled(TRUE); \
  1052. func((UINT)wParam, (LPRECT)lParam); \
  1053. lResult = TRUE; \
  1054. if(IsMsgHandled()) \
  1055. return TRUE; \
  1056. }
  1057. #define MSG_WM_MOVING(func) \
  1058. if (uMsg == WM_MOVING) \
  1059. { \
  1060. SetMsgHandled(TRUE); \
  1061. func((UINT)wParam, (LPRECT)lParam); \
  1062. lResult = TRUE; \
  1063. if(IsMsgHandled()) \
  1064. return TRUE; \
  1065. }
  1066. #define MSG_WM_CAPTURECHANGED(func) \
  1067. if (uMsg == WM_CAPTURECHANGED) \
  1068. { \
  1069. SetMsgHandled(TRUE); \
  1070. func((HWND)lParam); \
  1071. lResult = 0; \
  1072. if(IsMsgHandled()) \
  1073. return TRUE; \
  1074. }
  1075. #define MSG_WM_DEVICECHANGE(func) \
  1076. if (uMsg == WM_DEVICECHANGE) \
  1077. { \
  1078. SetMsgHandled(TRUE); \
  1079. lResult = (LRESULT)func((UINT)wParam, (DWORD)lParam); \
  1080. if(IsMsgHandled()) \
  1081. return TRUE; \
  1082. }
  1083. #define MSG_WM_COMMAND(func) \
  1084. if (uMsg == WM_COMMAND) \
  1085. { \
  1086. SetMsgHandled(TRUE); \
  1087. func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
  1088. lResult = 0; \
  1089. if(IsMsgHandled()) \
  1090. return TRUE; \
  1091. }
  1092. #define MSG_WM_DISPLAYCHANGE(func) \
  1093. if (uMsg == WM_DISPLAYCHANGE) \
  1094. { \
  1095. SetMsgHandled(TRUE); \
  1096. func((UINT)wParam, CSize(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  1097. lResult = 0; \
  1098. if(IsMsgHandled()) \
  1099. return TRUE; \
  1100. }
  1101. #define MSG_WM_ENTERSIZEMOVE(func) \
  1102. if (uMsg == WM_ENTERSIZEMOVE) \
  1103. { \
  1104. SetMsgHandled(TRUE); \
  1105. func(); \
  1106. lResult = 0; \
  1107. if(IsMsgHandled()) \
  1108. return TRUE; \
  1109. }
  1110. #define MSG_WM_EXITSIZEMOVE(func) \
  1111. if (uMsg == WM_EXITSIZEMOVE) \
  1112. { \
  1113. SetMsgHandled(TRUE); \
  1114. func(); \
  1115. lResult = 0; \
  1116. if(IsMsgHandled()) \
  1117. return TRUE; \
  1118. }
  1119. #define MSG_WM_GETFONT(func) \
  1120. if (uMsg == WM_GETFONT) \
  1121. { \
  1122. SetMsgHandled(TRUE); \
  1123. lResult = (LRESULT)func(); \
  1124. if(IsMsgHandled()) \
  1125. return TRUE; \
  1126. }
  1127. #define MSG_WM_GETHOTKEY(func) \
  1128. if (uMsg == WM_GETHOTKEY) \
  1129. { \
  1130. SetMsgHandled(TRUE); \
  1131. lResult = func(); \
  1132. if(IsMsgHandled()) \
  1133. return TRUE; \
  1134. }
  1135. #define MSG_WM_GETICON(func) \
  1136. if (uMsg == WM_GETICON) \
  1137. { \
  1138. SetMsgHandled(TRUE); \
  1139. lResult = (LRESULT)func((UINT)wParam); \
  1140. if(IsMsgHandled()) \
  1141. return TRUE; \
  1142. }
  1143. #define MSG_WM_GETTEXT(func) \
  1144. if (uMsg == WM_GETTEXT) \
  1145. { \
  1146. SetMsgHandled(TRUE); \
  1147. lResult = (LRESULT)func((int)wParam, (LPTSTR)lParam); \
  1148. if(IsMsgHandled()) \
  1149. return TRUE; \
  1150. }
  1151. #define MSG_WM_GETTEXTLENGTH(func) \
  1152. if (uMsg == WM_GETTEXTLENGTH) \
  1153. { \
  1154. SetMsgHandled(TRUE); \
  1155. lResult = (LRESULT)func(); \
  1156. if(IsMsgHandled()) \
  1157. return TRUE; \
  1158. }
  1159. #define MSG_WM_HELP(func) \
  1160. if (uMsg == WM_HELP) \
  1161. { \
  1162. SetMsgHandled(TRUE); \
  1163. func((LPHELPINFO)lParam); \
  1164. lResult = TRUE; \
  1165. if(IsMsgHandled()) \
  1166. return TRUE; \
  1167. }
  1168. #define MSG_WM_HOTKEY(func) \
  1169. if (uMsg == WM_HOTKEY) \
  1170. { \
  1171. SetMsgHandled(TRUE); \
  1172. func((int)wParam, (UINT)LOWORD(lParam), (UINT)HIWORD(lParam)); \
  1173. lResult = 0; \
  1174. if(IsMsgHandled()) \
  1175. return TRUE; \
  1176. }
  1177. #define MSG_WM_INPUTLANGCHANGE(func) \
  1178. if (uMsg == WM_INPUTLANGCHANGE) \
  1179. { \
  1180. SetMsgHandled(TRUE); \
  1181. func((DWORD)wParam, (HKL)lParam); \
  1182. lResult = TRUE; \
  1183. if(IsMsgHandled()) \
  1184. return TRUE; \
  1185. }
  1186. #define MSG_WM_INPUTLANGCHANGEREQUEST(func) \
  1187. if (uMsg == WM_INPUTLANGCHANGEREQUEST) \
  1188. { \
  1189. SetMsgHandled(TRUE); \
  1190. func((BOOL)wParam, (HKL)lParam); \
  1191. lResult = 0; \
  1192. if(IsMsgHandled()) \
  1193. return TRUE; \
  1194. }
  1195. #define MSG_WM_NEXTDLGCTL(func) \
  1196. if (uMsg == WM_NEXTDLGCTL) \
  1197. { \
  1198. SetMsgHandled(TRUE); \
  1199. func((BOOL)LOWORD(lParam), wParam); \
  1200. lResult = 0; \
  1201. if(IsMsgHandled()) \
  1202. return TRUE; \
  1203. }
  1204. #define MSG_WM_NEXTMENU(func) \
  1205. if (uMsg == WM_NEXTMENU) \
  1206. { \
  1207. SetMsgHandled(TRUE); \
  1208. func((int)wParam, (LPMDINEXTMENU)lParam); \
  1209. lResult = 0; \
  1210. if(IsMsgHandled()) \
  1211. return TRUE; \
  1212. }
  1213. #define MSG_WM_NOTIFYFORMAT(func) \
  1214. if (uMsg == WM_NOTIFYFORMAT) \
  1215. { \
  1216. SetMsgHandled(TRUE); \
  1217. lResult = (LRESULT)func((HWND)wParam, (int)lParam); \
  1218. if(IsMsgHandled()) \
  1219. return TRUE; \
  1220. }
  1221. #define MSG_WM_POWERBROADCAST(func) \
  1222. if (uMsg == WM_POWERBROADCAST) \
  1223. { \
  1224. SetMsgHandled(TRUE); \
  1225. lResult = (LRESULT)func((DWORD)wParam, (DWORD)lParam); \
  1226. if(IsMsgHandled()) \
  1227. return TRUE; \
  1228. }
  1229. #define MSG_WM_PRINT(func) \
  1230. if (uMsg == WM_PRINT) \
  1231. { \
  1232. SetMsgHandled(TRUE); \
  1233. func((HDC)wParam, (UINT)lParam); \
  1234. lResult = 0; \
  1235. if(IsMsgHandled()) \
  1236. return TRUE; \
  1237. }
  1238. #define MSG_WM_PRINTCLIENT(func) \
  1239. if (uMsg == WM_PRINTCLIENT) \
  1240. { \
  1241. SetMsgHandled(TRUE); \
  1242. func((HDC)wParam, (UINT)lParam); \
  1243. lResult = 0; \
  1244. if(IsMsgHandled()) \
  1245. return TRUE; \
  1246. }
  1247. #define MSG_WM_RASDIALEVENT(func) \
  1248. if (uMsg == WM_RASDIALEVENT) \
  1249. { \
  1250. SetMsgHandled(TRUE); \
  1251. func((RASCONNSTATE)wParam, (DWORD)lParam); \
  1252. lResult = TRUE; \
  1253. if(IsMsgHandled()) \
  1254. return TRUE; \
  1255. }
  1256. #define MSG_WM_SETFONT(func) \
  1257. if (uMsg == WM_SETFONT) \
  1258. { \
  1259. SetMsgHandled(TRUE); \
  1260. func((HFONT)wParam, (BOOL)LOWORD(lParam)); \
  1261. lResult = 0; \
  1262. if(IsMsgHandled()) \
  1263. return TRUE; \
  1264. }
  1265. #define MSG_WM_SETHOTKEY(func) \
  1266. if (uMsg == WM_SETHOTKEY) \
  1267. { \
  1268. SetMsgHandled(TRUE); \
  1269. lResult = (LRESULT)func((int)LOBYTE(LOWORD(wParam)), (UINT)HIBYTE(LOWORD(wParam))); \
  1270. if(IsMsgHandled()) \
  1271. return TRUE; \
  1272. }
  1273. #define MSG_WM_SETICON(func) \
  1274. if (uMsg == WM_SETICON) \
  1275. { \
  1276. SetMsgHandled(TRUE); \
  1277. lResult = (LRESULT)func((UINT)wParam, (HICON)lParam); \
  1278. if(IsMsgHandled()) \
  1279. return TRUE; \
  1280. }
  1281. #define MSG_WM_SETREDRAW(func) \
  1282. if (uMsg == WM_SETREDRAW) \
  1283. { \
  1284. SetMsgHandled(TRUE); \
  1285. func((BOOL)wParam); \
  1286. lResult = 0; \
  1287. if(IsMsgHandled()) \
  1288. return TRUE; \
  1289. }
  1290. #define MSG_WM_SETTEXT(func) \
  1291. if (uMsg == WM_SETTEXT) \
  1292. { \
  1293. SetMsgHandled(TRUE); \
  1294. lResult = (LRESULT)func((LPCTSTR)lParam); \
  1295. if(IsMsgHandled()) \
  1296. return TRUE; \
  1297. }
  1298. #define MSG_WM_USERCHANGED(func) \
  1299. if (uMsg == WM_USERCHANGED) \
  1300. { \
  1301. SetMsgHandled(TRUE); \
  1302. func(); \
  1303. lResult = 0; \
  1304. if(IsMsgHandled()) \
  1305. return TRUE; \
  1306. }
  1307. ///////////////////////////////////////////////////////////////////////////////
  1308. // New NT4 & NT5 messages
  1309. #if(_WIN32_WINNT >= 0x0400)
  1310. #define MSG_WM_MOUSEHOVER(func) \
  1311. if (uMsg == WM_MOUSEHOVER) \
  1312. { \
  1313. SetMsgHandled(TRUE); \
  1314. func(wParam, CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  1315. lResult = 0; \
  1316. if(IsMsgHandled()) \
  1317. return TRUE; \
  1318. }
  1319. #define MSG_WM_MOUSELEAVE(func) \
  1320. if (uMsg == WM_MOUSELEAVE) \
  1321. { \
  1322. SetMsgHandled(TRUE); \
  1323. func(); \
  1324. lResult = 0; \
  1325. if(IsMsgHandled()) \
  1326. return TRUE; \
  1327. }
  1328. #endif /* _WIN32_WINNT >= 0x0400 */
  1329. #if(WINVER >= 0x0500)
  1330. #define MSG_WM_MENURBUTTONUP(func) \
  1331. if (uMsg == WM_MENURBUTTONUP) \
  1332. { \
  1333. SetMsgHandled(TRUE); \
  1334. func(wParam, (HMENU)lParam); \
  1335. lResult = 0; \
  1336. if(IsMsgHandled()) \
  1337. return TRUE; \
  1338. }
  1339. #define MSG_WM_MENUDRAG(func) \
  1340. if (uMsg == WM_MENUDRAG) \
  1341. { \
  1342. SetMsgHandled(TRUE); \
  1343. lResult = func(wParam, (HMENU)lParam); \
  1344. if(IsMsgHandled()) \
  1345. return TRUE; \
  1346. }
  1347. #define MSG_WM_MENUGETOBJECT(func) \
  1348. if (uMsg == WM_MENUGETOBJECT) \
  1349. { \
  1350. SetMsgHandled(TRUE); \
  1351. lResult = func((PMENUGETOBJECTINFO)lParam); \
  1352. if(IsMsgHandled()) \
  1353. return TRUE; \
  1354. }
  1355. #define MSG_WM_UNINITMENUPOPUP(func) \
  1356. if (uMsg == WM_UNINITMENUPOPUP) \
  1357. { \
  1358. SetMsgHandled(TRUE); \
  1359. func((UINT)HIWORD(lParam), (HMENU)wParam); \
  1360. lResult = 0; \
  1361. if(IsMsgHandled()) \
  1362. return TRUE; \
  1363. }
  1364. #define MSG_WM_MENUCOMMAND(func) \
  1365. if (uMsg == WM_MENUCOMMAND) \
  1366. { \
  1367. SetMsgHandled(TRUE); \
  1368. func(wParam, (HMENU)lParam); \
  1369. lResult = 0; \
  1370. if(IsMsgHandled()) \
  1371. return TRUE; \
  1372. }
  1373. #endif /* WINVER >= 0x0500 */
  1374. #if(_WIN32_WINNT >= 0x0500)
  1375. #define MSG_WM_APPCOMMAND(func) \
  1376. if (uMsg == WM_APPCOMMAND) \
  1377. { \
  1378. SetMsgHandled(TRUE); \
  1379. func((HWND)wParam, GET_APPCOMMAND_LPARAM(lParam), GET_DEVICE_LPARAM(lParam), GET_KEYSTATE_LPARAM(lParam)); \
  1380. lResult = 0; \
  1381. if(IsMsgHandled()) \
  1382. return TRUE; \
  1383. }
  1384. #define MSG_WM_NCXBUTTONDOWN(func) \
  1385. if (uMsg == WM_NCXBUTTONDOWN) \
  1386. { \
  1387. SetMsgHandled(TRUE); \
  1388. func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  1389. lResult = 0; \
  1390. if(IsMsgHandled()) \
  1391. return TRUE; \
  1392. }
  1393. #define MSG_WM_NCXBUTTONUP(func) \
  1394. if (uMsg == WM_NCXBUTTONUP) \
  1395. { \
  1396. SetMsgHandled(TRUE); \
  1397. func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  1398. lResult = 0; \
  1399. if(IsMsgHandled()) \
  1400. return TRUE; \
  1401. }
  1402. #define MSG_WM_NCXBUTTONDBLCLK(func) \
  1403. if (uMsg == WM_NCXBUTTONDBLCLK) \
  1404. { \
  1405. SetMsgHandled(TRUE); \
  1406. func(GET_XBUTTON_WPARAM(wParam), GET_NCHITTEST_WPARAM(wParam), CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  1407. lResult = 0; \
  1408. if(IsMsgHandled()) \
  1409. return TRUE; \
  1410. }
  1411. #define MSG_WM_XBUTTONDOWN(func) \
  1412. if (uMsg == WM_XBUTTONDOWN) \
  1413. { \
  1414. SetMsgHandled(TRUE); \
  1415. func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  1416. lResult = 0; \
  1417. if(IsMsgHandled()) \
  1418. return TRUE; \
  1419. }
  1420. #define MSG_WM_XBUTTONUP(func) \
  1421. if (uMsg == WM_XBUTTONUP) \
  1422. { \
  1423. SetMsgHandled(TRUE); \
  1424. func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  1425. lResult = 0; \
  1426. if(IsMsgHandled()) \
  1427. return TRUE; \
  1428. }
  1429. #define MSG_WM_XBUTTONDBLCLK(func) \
  1430. if (uMsg == WM_XBUTTONDBLCLK) \
  1431. { \
  1432. SetMsgHandled(TRUE); \
  1433. func(GET_XBUTTON_WPARAM(wParam), GET_KEYSTATE_WPARAM(wParam), CPoint(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))); \
  1434. lResult = 0; \
  1435. if(IsMsgHandled()) \
  1436. return TRUE; \
  1437. }
  1438. #endif //(_WIN32_WINNT >= 0x0500)
  1439. ///////////////////////////////////////////////////////////////////////////////
  1440. // ATL defined messages
  1441. #define MSG_WM_FORWARDMSG(func) \
  1442. if (uMsg == WM_FORWARDMSG) \
  1443. { \
  1444. SetMsgHandled(TRUE); \
  1445. lResult = (LRESULT)func((LPMSG)lParam, (DWORD)wParam); \
  1446. if(IsMsgHandled()) \
  1447. return TRUE; \
  1448. }
  1449. ///////////////////////////////////////////////////////////////////////////////
  1450. // Dialog specific messages
  1451. #define MSG_DM_GETDEFID(func) \
  1452. if (uMsg == DM_GETDEFID) \
  1453. { \
  1454. SetMsgHandled(TRUE); \
  1455. lResult = func(); \
  1456. if(IsMsgHandled()) \
  1457. return TRUE; \
  1458. }
  1459. #define MSG_DM_SETDEFID(func) \
  1460. if (uMsg == DM_SETDEFID) \
  1461. { \
  1462. SetMsgHandled(TRUE); \
  1463. func((UINT)wParam); \
  1464. lResult = TRUE; \
  1465. if(IsMsgHandled()) \
  1466. return TRUE; \
  1467. }
  1468. #define MSG_DM_REPOSITION(func) \
  1469. if (uMsg == DM_REPOSITION) \
  1470. { \
  1471. SetMsgHandled(TRUE); \
  1472. func(); \
  1473. lResult = 0; \
  1474. if(IsMsgHandled()) \
  1475. return TRUE; \
  1476. }
  1477. ///////////////////////////////////////////////////////////////////////////////
  1478. // Reflected messages
  1479. #define MSG_OCM_COMMAND(func) \
  1480. if (uMsg == OCM_COMMAND) \
  1481. { \
  1482. SetMsgHandled(TRUE); \
  1483. func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
  1484. lResult = 0; \
  1485. if(IsMsgHandled()) \
  1486. return TRUE; \
  1487. }
  1488. #define MSG_OCM_NOTIFY(func) \
  1489. if (uMsg == OCM_NOTIFY) \
  1490. { \
  1491. SetMsgHandled(TRUE); \
  1492. lResult = func((int)wParam, (LPNMHDR)lParam); \
  1493. if(IsMsgHandled()) \
  1494. return TRUE; \
  1495. }
  1496. #define MSG_OCM_PARENTNOTIFY(func) \
  1497. if (uMsg == OCM_PARENTNOTIFY) \
  1498. { \
  1499. SetMsgHandled(TRUE); \
  1500. func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), lParam); \
  1501. lResult = 0; \
  1502. if(IsMsgHandled()) \
  1503. return TRUE; \
  1504. }
  1505. #define MSG_OCM_DRAWITEM(func) \
  1506. if (uMsg == OCM_DRAWITEM) \
  1507. { \
  1508. SetMsgHandled(TRUE); \
  1509. func((UINT)wParam, (LPDRAWITEMSTRUCT)lParam); \
  1510. lResult = TRUE; \
  1511. if(IsMsgHandled()) \
  1512. return TRUE; \
  1513. }
  1514. #define MSG_OCM_MEASUREITEM(func) \
  1515. if (uMsg == OCM_MEASUREITEM) \
  1516. { \
  1517. SetMsgHandled(TRUE); \
  1518. func((UINT)wParam, (LPMEASUREITEMSTRUCT)lParam); \
  1519. lResult = TRUE; \
  1520. if(IsMsgHandled()) \
  1521. return TRUE; \
  1522. }
  1523. #define MSG_OCM_COMPAREITEM(func) \
  1524. if (uMsg == OCM_COMPAREITEM) \
  1525. { \
  1526. SetMsgHandled(TRUE); \
  1527. lResult = (LRESULT)func((UINT)wParam, (LPCOMPAREITEMSTRUCT)lParam); \
  1528. if(IsMsgHandled()) \
  1529. return TRUE; \
  1530. }
  1531. #define MSG_OCM_DELETEITEM(func) \
  1532. if (uMsg == OCM_DELETEITEM) \
  1533. { \
  1534. SetMsgHandled(TRUE); \
  1535. func((UINT)wParam, (LPDELETEITEMSTRUCT)lParam); \
  1536. lResult = TRUE; \
  1537. if(IsMsgHandled()) \
  1538. return TRUE; \
  1539. }
  1540. #define MSG_OCM_VKEYTOITEM(func) \
  1541. if (uMsg == OCM_VKEYTOITEM) \
  1542. { \
  1543. SetMsgHandled(TRUE); \
  1544. lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
  1545. if(IsMsgHandled()) \
  1546. return TRUE; \
  1547. }
  1548. #define MSG_OCM_CHARTOITEM(func) \
  1549. if (uMsg == OCM_CHARTOITEM) \
  1550. { \
  1551. SetMsgHandled(TRUE); \
  1552. lResult = (LRESULT)func((UINT)LOWORD(wParam), (UINT)HIWORD(wParam), (HWND)lParam); \
  1553. if(IsMsgHandled()) \
  1554. return TRUE; \
  1555. }
  1556. #define MSG_OCM_HSCROLL(func) \
  1557. if (uMsg == OCM_HSCROLL) \
  1558. { \
  1559. SetMsgHandled(TRUE); \
  1560. func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
  1561. lResult = 0; \
  1562. if(IsMsgHandled()) \
  1563. return TRUE; \
  1564. }
  1565. #define MSG_OCM_VSCROLL(func) \
  1566. if (uMsg == OCM_VSCROLL) \
  1567. { \
  1568. SetMsgHandled(TRUE); \
  1569. func((int)LOWORD(wParam), (short)HIWORD(wParam), (HWND)lParam); \
  1570. lResult = 0; \
  1571. if(IsMsgHandled()) \
  1572. return TRUE; \
  1573. }
  1574. #define MSG_OCM_CTLCOLOREDIT(func) \
  1575. if (uMsg == OCM_CTLCOLOREDIT) \
  1576. { \
  1577. SetMsgHandled(TRUE); \
  1578. lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
  1579. if(IsMsgHandled()) \
  1580. return TRUE; \
  1581. }
  1582. #define MSG_OCM_CTLCOLORLISTBOX(func) \
  1583. if (uMsg == OCM_CTLCOLORLISTBOX) \
  1584. { \
  1585. SetMsgHandled(TRUE); \
  1586. lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
  1587. if(IsMsgHandled()) \
  1588. return TRUE; \
  1589. }
  1590. #define MSG_OCM_CTLCOLORBTN(func) \
  1591. if (uMsg == OCM_CTLCOLORBTN) \
  1592. { \
  1593. SetMsgHandled(TRUE); \
  1594. lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
  1595. if(IsMsgHandled()) \
  1596. return TRUE; \
  1597. }
  1598. #define MSG_OCM_CTLCOLORDLG(func) \
  1599. if (uMsg == OCM_CTLCOLORDLG) \
  1600. { \
  1601. SetMsgHandled(TRUE); \
  1602. lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
  1603. if(IsMsgHandled()) \
  1604. return TRUE; \
  1605. }
  1606. #define MSG_OCM_CTLCOLORSCROLLBAR(func) \
  1607. if (uMsg == OCM_CTLCOLORSCROLLBAR) \
  1608. { \
  1609. SetMsgHandled(TRUE); \
  1610. lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
  1611. if(IsMsgHandled()) \
  1612. return TRUE; \
  1613. }
  1614. #define MSG_OCM_CTLCOLORSTATIC(func) \
  1615. if (uMsg == OCM_CTLCOLORSTATIC) \
  1616. { \
  1617. SetMsgHandled(TRUE); \
  1618. lResult = (LRESULT)func((HDC)wParam, (HWND)lParam); \
  1619. if(IsMsgHandled()) \
  1620. return TRUE; \
  1621. }
  1622. ///////////////////////////////////////////////////////////////////////////////
  1623. // Edit specific messages
  1624. #define MSG_WM_CLEAR(func) \
  1625. if (uMsg == WM_CLEAR) \
  1626. { \
  1627. SetMsgHandled(TRUE); \
  1628. func(); \
  1629. lResult = 0; \
  1630. if(IsMsgHandled()) \
  1631. return TRUE; \
  1632. }
  1633. #define MSG_WM_COPY(func) \
  1634. if (uMsg == WM_COPY) \
  1635. { \
  1636. SetMsgHandled(TRUE); \
  1637. func(); \
  1638. lResult = 0; \
  1639. if(IsMsgHandled()) \
  1640. return TRUE; \
  1641. }
  1642. #define MSG_WM_CUT(func) \
  1643. if (uMsg == WM_CUT) \
  1644. { \
  1645. SetMsgHandled(TRUE); \
  1646. func(); \
  1647. lResult = 0; \
  1648. if(IsMsgHandled()) \
  1649. return TRUE; \
  1650. }
  1651. #define MSG_WM_PASTE(func) \
  1652. if (uMsg == WM_PASTE) \
  1653. { \
  1654. SetMsgHandled(TRUE); \
  1655. func(); \
  1656. lResult = 0; \
  1657. if(IsMsgHandled()) \
  1658. return TRUE; \
  1659. }
  1660. #define MSG_WM_UNDO(func) \
  1661. if (uMsg == WM_UNDO) \
  1662. { \
  1663. SetMsgHandled(TRUE); \
  1664. func(); \
  1665. lResult = 0; \
  1666. if(IsMsgHandled()) \
  1667. return TRUE; \
  1668. }
  1669. ///////////////////////////////////////////////////////////////////////////////
  1670. // Generic message handlers
  1671. #define MESSAGE_HANDLER_EX(msg, func) \
  1672. if(uMsg == msg) \
  1673. { \
  1674. SetMsgHandled(TRUE); \
  1675. lResult = func(uMsg, wParam, lParam); \
  1676. if(IsMsgHandled()) \
  1677. return TRUE; \
  1678. }
  1679. #define MESSAGE_RANGE_HANDLER_EX(msgFirst, msgLast, func) \
  1680. if(uMsg >= msgFirst && uMsg <= msgLast) \
  1681. { \
  1682. SetMsgHandled(TRUE); \
  1683. lResult = func(uMsg, wParam, lParam); \
  1684. if(IsMsgHandled()) \
  1685. return TRUE; \
  1686. }
  1687. ///////////////////////////////////////////////////////////////////////////////
  1688. // Commands and notifications
  1689. #define COMMAND_HANDLER_EX(id, code, func) \
  1690. if (uMsg == WM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) \
  1691. { \
  1692. SetMsgHandled(TRUE); \
  1693. func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
  1694. lResult = 0; \
  1695. if(IsMsgHandled()) \
  1696. return TRUE; \
  1697. }
  1698. #define COMMAND_ID_HANDLER_EX(id, func) \
  1699. if (uMsg == WM_COMMAND && id == LOWORD(wParam)) \
  1700. { \
  1701. SetMsgHandled(TRUE); \
  1702. func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
  1703. lResult = 0; \
  1704. if(IsMsgHandled()) \
  1705. return TRUE; \
  1706. }
  1707. #define COMMAND_CODE_HANDLER_EX(code, func) \
  1708. if (uMsg == WM_COMMAND && code == HIWORD(wParam)) \
  1709. { \
  1710. SetMsgHandled(TRUE); \
  1711. func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
  1712. lResult = 0; \
  1713. if(IsMsgHandled()) \
  1714. return TRUE; \
  1715. }
  1716. #define NOTIFY_HANDLER_EX(id, cd, func) \
  1717. if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom) \
  1718. { \
  1719. SetMsgHandled(TRUE); \
  1720. lResult = func((LPNMHDR)lParam); \
  1721. if(IsMsgHandled()) \
  1722. return TRUE; \
  1723. }
  1724. #define NOTIFY_ID_HANDLER_EX(id, func) \
  1725. if (uMsg == WM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \
  1726. { \
  1727. SetMsgHandled(TRUE); \
  1728. lResult = func((LPNMHDR)lParam); \
  1729. if(IsMsgHandled()) \
  1730. return TRUE; \
  1731. }
  1732. #define NOTIFY_CODE_HANDLER_EX(cd, func) \
  1733. if (uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \
  1734. { \
  1735. SetMsgHandled(TRUE); \
  1736. lResult = func((LPNMHDR)lParam); \
  1737. if(IsMsgHandled()) \
  1738. return TRUE; \
  1739. }
  1740. #define COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \
  1741. if(uMsg == WM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
  1742. { \
  1743. SetMsgHandled(TRUE); \
  1744. func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
  1745. lResult = 0; \
  1746. if(IsMsgHandled()) \
  1747. return TRUE; \
  1748. }
  1749. #define COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \
  1750. if(uMsg == WM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
  1751. { \
  1752. SetMsgHandled(TRUE); \
  1753. func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
  1754. lResult = 0; \
  1755. if(IsMsgHandled()) \
  1756. return TRUE; \
  1757. }
  1758. #define NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \
  1759. if(uMsg == WM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
  1760. { \
  1761. SetMsgHandled(TRUE); \
  1762. lResult = func((LPNMHDR)lParam); \
  1763. if(IsMsgHandled()) \
  1764. return TRUE; \
  1765. }
  1766. #define NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \
  1767. if(uMsg == WM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
  1768. { \
  1769. SetMsgHandled(TRUE); \
  1770. lResult = func((LPNMHDR)lParam); \
  1771. if(IsMsgHandled()) \
  1772. return TRUE; \
  1773. }
  1774. #define REFLECTED_COMMAND_HANDLER_EX(id, code, func) \
  1775. if (uMsg == OCM_COMMAND && code == HIWORD(wParam) && id == LOWORD(wParam)) \
  1776. { \
  1777. SetMsgHandled(TRUE); \
  1778. func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
  1779. lResult = 0; \
  1780. if(IsMsgHandled()) \
  1781. return TRUE; \
  1782. }
  1783. #define REFLECTED_COMMAND_ID_HANDLER_EX(id, func) \
  1784. if (uMsg == OCM_COMMAND && id == LOWORD(wParam)) \
  1785. { \
  1786. SetMsgHandled(TRUE); \
  1787. func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
  1788. lResult = 0; \
  1789. if(IsMsgHandled()) \
  1790. return TRUE; \
  1791. }
  1792. #define REFLECTED_COMMAND_CODE_HANDLER_EX(code, func) \
  1793. if (uMsg == OCM_COMMAND && code == HIWORD(wParam)) \
  1794. { \
  1795. SetMsgHandled(TRUE); \
  1796. func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
  1797. lResult = 0; \
  1798. if(IsMsgHandled()) \
  1799. return TRUE; \
  1800. }
  1801. #define REFLECTED_NOTIFY_HANDLER_EX(id, cd, func) \
  1802. if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && id == ((LPNMHDR)lParam)->idFrom) \
  1803. { \
  1804. SetMsgHandled(TRUE); \
  1805. lResult = func((LPNMHDR)lParam); \
  1806. if(IsMsgHandled()) \
  1807. return TRUE; \
  1808. }
  1809. #define REFLECTED_NOTIFY_ID_HANDLER_EX(id, func) \
  1810. if (uMsg == OCM_NOTIFY && id == ((LPNMHDR)lParam)->idFrom) \
  1811. { \
  1812. SetMsgHandled(TRUE); \
  1813. lResult = func((LPNMHDR)lParam); \
  1814. if(IsMsgHandled()) \
  1815. return TRUE; \
  1816. }
  1817. #define REFLECTED_NOTIFY_CODE_HANDLER_EX(cd, func) \
  1818. if (uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code) \
  1819. { \
  1820. SetMsgHandled(TRUE); \
  1821. lResult = func((LPNMHDR)lParam); \
  1822. if(IsMsgHandled()) \
  1823. return TRUE; \
  1824. }
  1825. #define REFLECTED_COMMAND_RANGE_HANDLER_EX(idFirst, idLast, func) \
  1826. if(uMsg == OCM_COMMAND && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
  1827. { \
  1828. SetMsgHandled(TRUE); \
  1829. func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
  1830. lResult = 0; \
  1831. if(IsMsgHandled()) \
  1832. return TRUE; \
  1833. }
  1834. #define REFLECTED_COMMAND_RANGE_CODE_HANDLER_EX(idFirst, idLast, code, func) \
  1835. if(uMsg == OCM_COMMAND && code == HIWORD(wParam) && LOWORD(wParam) >= idFirst && LOWORD(wParam) <= idLast) \
  1836. { \
  1837. SetMsgHandled(TRUE); \
  1838. func((UINT)HIWORD(wParam), (int)LOWORD(wParam), (HWND)lParam); \
  1839. lResult = 0; \
  1840. if(IsMsgHandled()) \
  1841. return TRUE; \
  1842. }
  1843. #define REFLECTED_NOTIFY_RANGE_HANDLER_EX(idFirst, idLast, func) \
  1844. if(uMsg == OCM_NOTIFY && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
  1845. { \
  1846. SetMsgHandled(TRUE); \
  1847. lResult = func((LPNMHDR)lParam); \
  1848. if(IsMsgHandled()) \
  1849. return TRUE; \
  1850. }
  1851. #define REFLECTED_NOTIFY_RANGE_CODE_HANDLER_EX(idFirst, idLast, cd, func) \
  1852. if(uMsg == OCM_NOTIFY && cd == ((LPNMHDR)lParam)->code && ((LPNMHDR)lParam)->idFrom >= idFirst && ((LPNMHDR)lParam)->idFrom <= idLast) \
  1853. { \
  1854. SetMsgHandled(TRUE); \
  1855. lResult = func((LPNMHDR)lParam); \
  1856. if(IsMsgHandled()) \
  1857. return TRUE; \
  1858. }
  1859. #endif //__ATLCRACK_H__