common.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef _NULLSOFT_WINAMP_ML_DEVICES_COMMON_HEADER
  2. #define _NULLSOFT_WINAMP_ML_DEVICES_COMMON_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #ifndef LONGX86
  7. #ifdef _WIN64
  8. #define LONGX86 LONG_PTR
  9. #else /*_WIN64*/
  10. #define LONGX86 LONG
  11. #endif /*_WIN64*/
  12. #endif // LONGX86
  13. #define CSTR_INVARIANT MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT)
  14. #ifdef __cplusplus
  15. #define SENDMSG(__hwnd, __msgId, __wParam, __lParam) ::SendMessageW((__hwnd), (__msgId), (__wParam), (__lParam))
  16. #else
  17. #define SENDMSG(__hwnd, __msgId, __wParam, __lParam) SendMessageW((__hwnd), (__msgId), (__wParam), (__lParam))
  18. #endif // __cplusplus
  19. #define SENDMLIPC(__hwndML, __ipcMsgId, __param) SENDMSG((__hwndML), WM_ML_IPC, (WPARAM)(__param), (LPARAM)(__ipcMsgId))
  20. #define SENDWAIPC(__hwndWA, __ipcMsgId, __param) SENDMSG((__hwndWA), WM_WA_IPC, (WPARAM)(__param), (LPARAM)(__ipcMsgId))
  21. #define SENDCMD(__hwnd, __ctrlId, __eventId, __hctrl) (SENDMSG((__hwnd), WM_COMMAND, MAKEWPARAM(__ctrlId, __eventId), (LPARAM)(__hctrl)))
  22. #define DIALOG_RESULT(__hwnd, __result) { SetWindowLongPtrW((__hwnd), DWLP_MSGRESULT, ((LONGX86)(LONG_PTR)(__result))); return TRUE; }
  23. #ifndef GetWindowStyle
  24. #define GetWindowStyle(__hwnd) ((UINT)GetWindowLongPtr((__hwnd), GWL_STYLE))
  25. #endif //GetWindowStyle
  26. #ifndef SetWindowStyle
  27. #define SetWindowStyle(__hwnd, __style) (SetWindowLongPtr((__hwnd), GWL_STYLE, (__style)))
  28. #endif //SetWindowStyle
  29. #ifndef GetWindowStyleEx
  30. #define GetWindowStyleEx(__hwnd) ((UINT)GetWindowLongPtr((__hwnd), GWL_EXSTYLE))
  31. #endif // GetWindowStyleEx
  32. #ifndef SetWindowStyleEx
  33. #define SetWindowStyleEx(__hwnd, __style) (SetWindowLongPtr((__hwnd), GWL_EXSTYLE, (__style)))
  34. #endif //SetWindowStyle
  35. #ifndef RECTWIDTH
  36. #define RECTWIDTH(__r) ((__r).right - (__r).left)
  37. #endif
  38. #ifndef RECTHEIGHT
  39. #define RECTHEIGHT(__r) ((__r).bottom - (__r).top)
  40. #endif
  41. #undef CLAMP
  42. #define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
  43. #ifndef ARRAYSIZE
  44. #define ARRAYSIZE(_a) (sizeof(_a)/sizeof((_a)[0]))
  45. #endif
  46. #ifndef ABS
  47. #define ABS(x) (((x) > 0) ? (x) : (-x))
  48. #endif
  49. #ifndef MIN
  50. #define MIN(v1, v2) (((v1) < (v2)) ? (v1) : (v2))
  51. #endif
  52. #ifndef MAX
  53. #define MAX(v1, v2) (((v1) > (v2)) ? (v1) : (v2))
  54. #endif
  55. #endif //_NULLSOFT_WINAMP_ML_DEVICES_COMMON_HEADER