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.

123 lines
3.7 KiB

  1. #ifndef _CMN_HDR_H_
  2. #define _CMN_HDR_H_
  3. //----------------------------------------------------------------
  4. //helper Macro definition
  5. //----------------------------------------------------------------
  6. // show message at compile time with #pragma
  7. // (e.g.)
  8. // in source code, write these line
  9. // #pragma chMSG(Show message at compile time)
  10. // #pragma msgNOIMP
  11. //----------------------------------------------------------------
  12. #define chSTR1(a) #a
  13. #define chSTR2(a) chSTR1(a)
  14. #define chMSG(desc) message(__FILE__ "(" chSTR2(__LINE__) ") : "#desc)
  15. #define msgNOIMP chMSG(<=====Not Impelemnted yet ======)
  16. //----------------------------------------------------------------
  17. // Get Array's count
  18. //----------------------------------------------------------------
  19. #define ArrayCount(a) ((sizeof(a))/(sizeof((a)[0])))
  20. //----------------------------------------------------------------
  21. //Declare string explicitly
  22. //----------------------------------------------------------------
  23. #define UTEXT(a) L ## a //L"XXXXXX"
  24. #define ATEXT(a) a //"xxxxxx"
  25. //----------------------------------------------------------------
  26. //remove Ugly warning
  27. //----------------------------------------------------------------
  28. #define UNREF UNREFERENCED_PARAMETER
  29. #define UNREF_FOR_MSG() UNREF(hwnd);\
  30. UNREF(uMsg);\
  31. UNREF(wParam);\
  32. UNREF(lParam)
  33. #define UNREF_FOR_CMD() UNREF(hwnd);\
  34. UNREF(wCommand);\
  35. UNREF(wNotify);\
  36. UNREF(hwndCtrl)
  37. #define Unref UNREFERENCED_PARAMETER
  38. #define Unref1(a) Unref(a)
  39. #define Unref2(a,b) Unref(a);Unref(b)
  40. #define Unref3(a,b,c) Unref(a);Unref(b);Unref(c)
  41. #define Unref4(a,b,c,d) Unref(a);Unref(b);Unref(c);Unref(d)
  42. #define UnrefMsg() Unref(hwnd);Unref(wParam);Unref(lParam)
  43. #pragma warning (disable:4127)
  44. #pragma warning (disable:4244)
  45. #pragma warning (disable:4706)
  46. //----------------------------------------------------------------
  47. //990810:ToshiaK for Win64
  48. //Wrapper function for Set(Get)WindowLong/Set(Get)WindowLongPtr
  49. // LPVOID WinGetPtr(HWND hwnd, INT index);
  50. // LPVOID WinSetPtr(HWND hwnd, INT index, LPVOID lpVoid);
  51. // LPVOID WinSetUserPtr(HWND hwnd, LPVOID lpVoid);
  52. // LPVOID WinGetUserPtr(HWND hwnd);
  53. // WNDPROC WinSetWndProc(HWND hwnd, WNDPROC lpfnWndProc);
  54. // WNDPROC WinGetWndProc(HWND hwnd);
  55. //----------------------------------------------------------------
  56. inline LPVOID
  57. WinGetPtr(HWND hwnd, INT index)
  58. {
  59. #ifdef _WIN64
  60. return (LPVOID)::GetWindowLongPtr(hwnd, index);
  61. #else
  62. return (LPVOID)::GetWindowLong(hwnd, index);
  63. #endif
  64. }
  65. inline LPVOID
  66. WinSetPtr(HWND hwnd, INT index, LPVOID lpVoid)
  67. {
  68. #ifdef _WIN64
  69. return (LPVOID)::SetWindowLongPtr(hwnd, index, (LONG_PTR)lpVoid);
  70. #else
  71. return (LPVOID)::SetWindowLong(hwnd, index, (LONG)lpVoid);
  72. #endif
  73. }
  74. inline LPVOID
  75. WinSetUserPtr(HWND hwnd, LPVOID lpVoid)
  76. {
  77. #ifdef _WIN64
  78. return (LPVOID)::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lpVoid);
  79. #else
  80. return (LPVOID)::SetWindowLong(hwnd, GWL_USERDATA, (LONG)lpVoid);
  81. #endif
  82. }
  83. inline LPVOID
  84. WinGetUserPtr(HWND hwnd)
  85. {
  86. #ifdef _WIN64
  87. return (LPVOID)::GetWindowLongPtr(hwnd, GWLP_USERDATA);
  88. #else
  89. return (LPVOID)::GetWindowLong(hwnd, GWL_USERDATA);
  90. #endif
  91. }
  92. inline WNDPROC
  93. WinSetWndProc(HWND hwnd, WNDPROC lpfnWndProc)
  94. {
  95. #ifdef _WIN64
  96. return (WNDPROC)::SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)lpfnWndProc);
  97. #else
  98. return (WNDPROC)::SetWindowLong(hwnd, GWL_WNDPROC, (LONG)lpfnWndProc);
  99. #endif
  100. }
  101. inline WNDPROC
  102. WinGetWndProc(HWND hwnd)
  103. {
  104. #ifdef _WIN64
  105. return (WNDPROC)::GetWindowLongPtr(hwnd, GWLP_WNDPROC);
  106. #else
  107. return (WNDPROC)::GetWindowLong(hwnd, GWL_WNDPROC);
  108. #endif
  109. }
  110. #endif //_CMN_HDR_H_