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.

130 lines
4.6 KiB

  1. //****************************************************************************
  2. //
  3. // Copyright (c) 1992, Microsoft Corporation
  4. //
  5. // File: PORTABLE.H
  6. //
  7. // Definitions to simplify portability between WIN31 and WIN32
  8. //
  9. //****************************************************************************
  10. #ifndef _PORTABLE_H_
  11. #define _PORTABLE_H_
  12. #ifdef _NTWIN
  13. #ifndef WIN32
  14. #define WIN32
  15. #endif
  16. #endif
  17. #ifdef WIN32
  18. #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
  19. #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(wp)
  20. #define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
  21. #define GET_WINDOW_ID(hwnd) (UINT)GetWindowLong(hwnd, GWL_ID)
  22. #define GET_WINDOW_INSTANCE(hwnd) (HINSTANCE)GetWindowLong(hwnd, \
  23. GWL_HINSTANCE)
  24. #define LONG2POINT(l, pt) ((pt).x=(SHORT)LOWORD(l), (pt).y=(SHORT)HIWORD(l))
  25. #ifdef __cplusplus
  26. #define NOTIFYPARENT(hwnd,code) { \
  27. UINT nID; \
  28. nID = GET_WINDOW_ID(hwnd); \
  29. (::SendMessage)(::GetParent(hwnd), \
  30. WM_COMMAND, MAKEWPARAM(nID, code), \
  31. (LPARAM)hwnd); \
  32. }
  33. #define SENDCOMMAND(hwnd, cmd) { \
  34. (::SendMessage)(hwnd, WM_COMMAND, \
  35. MAKEWPARAM(cmd, 0), (LPARAM)0); \
  36. }
  37. #define POSTCOMMAND(hwnd, cmd) { \
  38. (::PostMessage)(hwnd, WM_COMMAND, \
  39. MAKEWPARAM(cmd, 0), (LPARAM)0); \
  40. }
  41. #else // !__cplusplus
  42. #define NOTIFYPARENT(hwnd,code) { \
  43. UINT nID; \
  44. nID = GET_WINDOW_ID(hwnd); \
  45. SendMessage(GetParent(hwnd), WM_COMMAND, \
  46. MAKEWPARAM(nID, code), \
  47. (LPARAM)hwnd); \
  48. }
  49. #define SENDCOMMAND(hwnd, cmd) { \
  50. SendMessage(hwnd, WM_COMMAND, \
  51. MAKEWPARAM(cmd, 0), (LPARAM)0); \
  52. }
  53. #define POSTCOMMAND(hwnd, cmd) { \
  54. PostMessage(hwnd, WM_COMMAND, \
  55. MAKEWPARAM(cmd, 0), (LPARAM)0); \
  56. }
  57. #endif // __cplusplus
  58. #else // !WIN32
  59. // Some type definitions excluded from win31 sdk...
  60. // Should these ever be defined for win31, GET RID OF THESE!
  61. typedef float FLOAT;
  62. typedef char TCHAR;
  63. #define GET_WM_COMMAND_ID(wp, lp) LOWORD(wp)
  64. #define GET_WM_COMMAND_CMD(wp, lp) HIWORD(lp)
  65. #define GET_WM_COMMAND_HWND(wp, lp) (HWND)LOWORD(lp)
  66. #define GET_WINDOW_ID(hwnd) (UINT)GetWindowWord(hwnd, GWW_ID)
  67. #define GET_WINDOW_INSTANCE(hwnd) (HINSTANCE)GetWindowWord(hwnd, \
  68. GWW_HINSTANCE)
  69. #define LONG2POINT(l, pt) ((pt).x = (int)LOWORD(l), (pt).y = (int)HIWORD(l))
  70. #ifdef __cplusplus
  71. #define NOTIFYPARENT(hwnd,code) { \
  72. UINT nID; \
  73. nID = GET_WINDOW_ID(hwnd); \
  74. (::SendMessage)(::GetParent(hwnd), \
  75. WM_COMMAND, nID, \
  76. MAKELPARAM(hwnd, code)); \
  77. }
  78. #define SENDCOMMAND(hwnd, cmd) { \
  79. (::SendMessage)(hwnd,WM_COMMAND,cmd,0); \
  80. }
  81. #define POSTCOMMAND(hwnd, cmd) { \
  82. (::PostMessage)(hwnd,WM_COMMAND,cmd,0); \
  83. }
  84. #else // !__cplusplus
  85. #define NOTIFYPARENT(hwnd,code) { \
  86. UINT nID; \
  87. nID = GET_WINDOW_ID(hwnd); \
  88. SendMessage(GetParent(hwnd), WM_COMMAND, \
  89. nID, MAKELPARAM(hwnd, code)); \
  90. }
  91. #define SENDCOMMAND(hwnd, cmd) { \
  92. SendMessage(hwnd, WM_COMMAND, cmd, 0); \
  93. }
  94. #define POSTCOMMAND(hwnd, cmd) { \
  95. PostMessage(hwnd, WM_COMMAND, cmd, 0); \
  96. }
  97. #endif // __cplusplus
  98. #endif // WIN32
  99. #endif // _PORTABLE_H_