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.

106 lines
4.1 KiB

  1. #ifndef __util_h__
  2. #define __util_h__
  3. #define ARRAY_SIZE( A ) ( sizeof(A) / sizeof(A[0]) )
  4. #define CCHMAX ARRAY_SIZE
  5. void ErrorMessage( void );
  6. void ErrorMessage( LPCTSTR str, HRESULT hr );
  7. HRESULT LPTSTR_to_BSTR(BSTR *pbstr, LPCTSTR psz);
  8. HRESULT BSTR_to_LPTSTR(LPTSTR *ppsz, BSTR bstr);
  9. #define RETFAIL( x ) if( false == ( x ) ) { ErrorMessage( "", GetLastError() ); assert( 0 ); return false; }
  10. #define RETNULL( x ) if( NULL == ( x ) ) { ErrorMessage( "", GetLastError() ); assert( 0 ); return NULL; }
  11. //-------------------------------------------------------------------
  12. // Track Bar Helper Macros
  13. //-------------------------------------------------------------------
  14. // Pilfered from Petzold, "Programming Windows 95", Chapter 12, comctlhlp.h
  15. #define TrackBar_ClearSel(hwnd, fRedraw) \
  16. (void)SendMessage((hwnd), TBM_CLEARSEL, (WPARAM) (BOOL) fRedraw, 0L)
  17. #define TrackBar_ClearTics(hwnd, fRedraw) \
  18. (void)SendMessage((hwnd), TBM_CLEARTICS, (WPARAM) (BOOL) fRedraw, 0L)
  19. #define TrackBar_GetChannelRect(hwnd, lprc) \
  20. (void)SendMessage((hwnd), TBM_GETCHANNELRECT, 0, (LPARAM) (LPRECT) lprc)
  21. #define TrackBar_GetLineSize(hwnd) \
  22. (LONG)SendMessage((hwnd), TBM_GETLINESIZE, 0, 0L)
  23. #define TrackBar_GetNumTics(hwnd) \
  24. (LONG)SendMessage((hwnd), TBM_GETNUMTICS, 0, 0L)
  25. #define TrackBar_GetPageSize(hwnd) \
  26. (LONG)SendMessage((hwnd), TBM_GETPAGESIZE, 0, 0L)
  27. #define TrackBar_GetPos(hwnd) \
  28. (LONG)SendMessage((hwnd), TBM_GETPOS, 0, 0L)
  29. #define TrackBar_GetPTics(hwnd) \
  30. (LPLONG)SendMessage((hwnd), TBM_GETPTICS, 0, 0L)
  31. #define TrackBar_GetRangeMax(hwnd) \
  32. (LONG)SendMessage((hwnd), TBM_GETRANGEMAX, 0, 0L)
  33. #define TrackBar_GetRangeMin(hwnd) \
  34. (LONG)SendMessage((hwnd), TBM_GETRANGEMIN, 0, 0L)
  35. #define TrackBar_GetSelEnd(hwnd) \
  36. (LONG)SendMessage((hwnd), TBM_GETSELEND, 0, 0L)
  37. #define TrackBar_GetSelStart(hwnd) \
  38. (LONG)SendMessage((hwnd), TBM_GETSELSTART, 0, 0L)
  39. #define TrackBar_GetThumbLength(hwnd) \
  40. (UINT)SendMessage((hwnd), TBM_GETTHUMBLENGTH, 0, 0L)
  41. #define TrackBar_GetThumbRect(hwnd, lprc) \
  42. (void)SendMessage((hwnd), TBM_GETTHUMBRECT, 0, (LPARAM) (LPRECT) lprc)
  43. #define TrackBar_GetTic(hwnd, iTic) \
  44. (LONG)SendMessage((hwnd), TBM_GETTIC, (WPARAM) (WORD) iTic, 0L)
  45. #define TrackBar_GetTicPos(hwnd, iTic) \
  46. (LONG)SendMessage((hwnd), TBM_GETTICPOS, (WPARAM) (WORD) iTic, 0L)
  47. #define TrackBar_SetLineSize(hwnd, lLineSize) \
  48. (LONG)SendMessage((hwnd), TBM_SETLINESIZE, 0, (LONG) lLineSize)
  49. #define TrackBar_SetPageSize(hwnd, lPageSize) \
  50. (LONG)SendMessage((hwnd), TBM_SETPAGESIZE, 0, (LONG) lPageSize)
  51. #define TrackBar_SetPos(hwnd, bPosition, lPosition) \
  52. (void)SendMessage((hwnd), TBM_SETPOS, (WPARAM) (BOOL) bPosition, (LPARAM) (LONG) lPosition)
  53. #define TrackBar_SetRange(hwnd, bRedraw, lMinimum, lMaximum) \
  54. (void)SendMessage((hwnd), TBM_SETRANGE, (WPARAM) (BOOL) bRedraw, (LPARAM) MAKELONG(lMinimum, lMaximum))
  55. #define TrackBar_SetRangeMax(hwnd, bRedraw, lMaximum) \
  56. (void)SendMessage((hwnd), TBM_SETRANGEMAX, (WPARAM) bRedraw, (LPARAM) lMaximum)
  57. #define TrackBar_SetRangeMin(hwnd, bRedraw, lMinimum) \
  58. (void)SendMessage((hwnd), TBM_SETRANGEMIN, (WPARAM) bRedraw, (LPARAM) lMinimum)
  59. #define TrackBar_SetSel(hwnd, bRedraw, lMinimum, lMaximum) \
  60. (void)SendMessage((hwnd), TBM_SETSEL, (WPARAM) (BOOL) bRedraw, (LPARAM) MAKELONG(lMinimum, lMaximum))
  61. #define TrackBar_SetSelEnd(hwnd, bRedraw, lEnd) \
  62. (void)SendMessage((hwnd), TBM_SETSELEND, (WPARAM) (BOOL) bRedraw, (LPARAM) (LONG) lEnd)
  63. #define TrackBar_SetSelStart(hwnd, bRedraw, lStart) \
  64. (void)SendMessage((hwnd), TBM_SETSELSTART, (WPARAM) (BOOL) bRedraw, (LPARAM) (LONG) lStart)
  65. #define TrackBar_SetThumbLength(hwnd, iLength) \
  66. (void)SendMessage((hwnd), TBM_SETTHUMBLENGTH, (WPARAM) (UINT) iLength, 0L)
  67. #define TrackBar_SetTic(hwnd, lPosition) \
  68. (BOOL)SendMessage((hwnd), TBM_SETTIC, 0, (LPARAM) (LONG) lPosition)
  69. #define TrackBar_SetTicFreq(hwnd, wFreq, lPosition) \
  70. (void)SendMessage((hwnd), TBM_SETTICFREQ, (WPARAM) wFreq, (LPARAM) (LONG) lPosition)
  71. #endif // __util_h__