Source code of Windows XP (NT5)
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.

173 lines
4.7 KiB

  1. // CWindow.h
  2. #ifndef _CWINDOW_H
  3. #define _CWINDOW_H
  4. #include <commctrl.h>
  5. #ifndef STRICT
  6. #define WNDPROC FARPROC
  7. #endif
  8. #if !defined(GWLP_USERDATA)
  9. #define GWLP_USERDATA GWL_USERDATA
  10. #define GWLP_WNDPROC GWL_WNDPROC
  11. #define DWLP_USER DWL_USER
  12. #define DWLP_MSGRESULT DWL_MSGRESULT
  13. #define SetWindowLongPtr SetWindowLong
  14. #define GetWindowLongPtr GetWindowLong
  15. #define INT_PTR LONG
  16. #endif
  17. #define WM_PARENT_WM_SIZE WM_USER+900
  18. #define SC_BEGIN_MESSAGE_HANDLERS(className) \
  19. className *This = NULL;\
  20. This = (className*)GetWindowLongPtr(hWnd,GWLP_USERDATA);\
  21. if (This == NULL) \
  22. {\
  23. This = new className(hWnd);\
  24. SetWindowLongPtr(hWnd,GWLP_USERDATA,(INT_PTR)This);\
  25. }\
  26. else if (WM_NCDESTROY == uMsg)\
  27. {\
  28. delete This;\
  29. This = NULL;\
  30. SetWindowLongPtr(hWnd,GWLP_USERDATA,0);\
  31. }\
  32. switch (uMsg)
  33. #define SC_HANDLE_MESSAGE(msg,handler) \
  34. case (msg):\
  35. {\
  36. if (This)\
  37. {\
  38. return This->handler( wParam, lParam );\
  39. }\
  40. }\
  41. break
  42. #define SC_HANDLE_MESSAGE_CALL_DEFAULT_TREEVIEW() \
  43. if(gTreeViewWndSysWndProc != NULL) {\
  44. CallWindowProc(gTreeViewWndSysWndProc, hWnd, uMsg, wParam,lParam);\
  45. }
  46. #define SC_HANDLE_MESSAGE_CALL_DEFAULT_LISTVIEW() \
  47. if(gListViewWndSysWndProc != NULL) {\
  48. CallWindowProc(gListViewWndSysWndProc, hWnd, uMsg, wParam,lParam);\
  49. }
  50. #define SC_HANDLE_MESSAGE_DEFAULT_TREEVIEW() \
  51. default:\
  52. {\
  53. if (This)\
  54. {\
  55. if(/*This->*/gTreeViewWndSysWndProc != NULL) {\
  56. return CallWindowProc(/*This->*/gTreeViewWndSysWndProc, hWnd, uMsg, wParam,lParam);\
  57. }\
  58. }\
  59. } \
  60. break
  61. #define SC_HANDLE_MESSAGE_DEFAULT_LISTVIEW() \
  62. default:\
  63. {\
  64. if (This)\
  65. {\
  66. if(/*This->*/gListViewWndSysWndProc != NULL) {\
  67. return CallWindowProc(/*This->*/gListViewWndSysWndProc, hWnd, uMsg, wParam,lParam);\
  68. }\
  69. }\
  70. } \
  71. break
  72. #define SC_FORWARD_MESSAGE(msg,hwndForward)\
  73. case (msg):\
  74. {\
  75. return SendMessage( hwndForward, msg, wParam, lParam );\
  76. }\
  77. break
  78. #define SC_END_MESSAGE_HANDLERS() \
  79. return (DefWindowProc(hWnd,uMsg,wParam,lParam))
  80. #define SC_HANDLE_REGISTERED_MESSAGE(msg,handler)\
  81. if (This && uMsg == This->msg)\
  82. {\
  83. return This->handler( wParam, lParam );\
  84. }
  85. #define SC_BEGIN_DIALOG_MESSAGE_HANDLERS(className) \
  86. UINT_PTR bRes = FALSE;\
  87. className *This = (className *)GetWindowLongPtr(hWnd,DWLP_USER);\
  88. if (WM_INITDIALOG == uMsg)\
  89. {\
  90. This = new className( hWnd );\
  91. SetWindowLongPtr(hWnd,DWLP_USER,(INT_PTR)This);\
  92. }\
  93. else if (WM_NCDESTROY == uMsg)\
  94. {\
  95. if (This)\
  96. delete This;\
  97. This = NULL;\
  98. SetWindowLongPtr(hWnd,DWLP_USER,(INT_PTR)This);\
  99. }\
  100. switch (uMsg)
  101. #define SC_HANDLE_DIALOG_MESSAGE(msg,handler) \
  102. case (msg):\
  103. {\
  104. if (This)\
  105. {\
  106. LRESULT lRes = This->handler( wParam, lParam );\
  107. if (WM_CTLCOLORBTN==msg || WM_CTLCOLORDLG==msg || WM_CTLCOLOREDIT==msg || WM_CTLCOLORLISTBOX==msg || WM_CTLCOLORMSGBOX==msg || WM_CTLCOLORSCROLLBAR==msg || WM_CTLCOLORSTATIC==msg)\
  108. bRes = (UINT_PTR)(lRes);\
  109. SetWindowLongPtr( hWnd, DWLP_MSGRESULT, (INT_PTR)lRes );\
  110. bRes = true;\
  111. }\
  112. }\
  113. break
  114. #define SC_HANDLE_REGISTERED_DIALOG_MESSAGE(msg,handler)\
  115. if (This && uMsg == This->msg)\
  116. {\
  117. LRESULT lRes = This->handler( wParam, lParam );\
  118. SetWindowLongPtr( hWnd, DWLP_MSGRESULT, (INT_PTR)lRes );\
  119. bRes = true;\
  120. }
  121. #define SC_END_DIALOG_MESSAGE_HANDLERS() \
  122. return (bRes)
  123. #define SC_BEGIN_NOTIFY_MESSAGE_HANDLERS()
  124. #define SC_HANDLE_NOTIFY_MESSAGE_CODE(_code,proc)\
  125. if ((_code) == ((LPNMHDR)lParam)->code)\
  126. return proc( wParam, lParam )
  127. #define SC_HANDLE_NOTIFY_MESSAGE_CONTROL(_code,id,proc)\
  128. if ((_code) == ((LPNMHDR)lParam)->code && (id) == (int)wParam)\
  129. return proc( wParam, lParam )
  130. #define SC_END_NOTIFY_MESSAGE_HANDLERS()\
  131. return 0;
  132. #define SC_BEGIN_COMMAND_HANDLERS()
  133. #define SC_HANDLE_COMMAND_NOTIFY(nCode,nIdCtl,handler)\
  134. if (nCode==(int)HIWORD(wParam) && nIdCtl==(int)LOWORD(wParam))\
  135. {\
  136. handler( wParam, lParam );\
  137. return (0);\
  138. }
  139. #define SC_HANDLE_COMMAND(nIdCtl,handler)\
  140. if (nIdCtl==(int)LOWORD(wParam))\
  141. {\
  142. handler( wParam, lParam );\
  143. return (0);\
  144. }
  145. #define SC_END_COMMAND_HANDLERS()\
  146. return (0)
  147. #endif