home *** CD-ROM | disk | FTP | other *** search
/ Windows Shareware GOLD / NuclearComputingVol3No1.cdr / _bbs3 / f1530.zip / WINSTD.H < prev   
C/C++ Source or Header  |  1991-08-22  |  2KB  |  68 lines

  1. /*
  2.  
  3. WINSTD.H
  4.  
  5. standard definitions for Windows source files
  6.  
  7. created:    STG        6/1/91
  8. modified:
  9.  
  10. */
  11.  
  12. /* standard dialog grouping options */
  13.  
  14. #define TABGRP    (WS_TABSTOP | WS_GROUP)
  15.  
  16. /* definition of macro to get the offset of a field in a structure */
  17. /* standardly defined in stddef.h, included here in case stddef.h not inc'd */
  18.  
  19. #ifndef offsetof
  20. #define offsetof(Struct, Member) \
  21.     (unsigned int) &(((Struct NEAR *)0)->Member)
  22. #endif
  23.  
  24. /*
  25. the following macros allow easy access to window and class extra bytes,
  26. based on offsets into defined a structure that "maps" onto the appropriate
  27. array of extra bytes
  28.  
  29. Modified from:
  30.     "Windows 3.0: A Developer's Guide", Jeffrey M. Richter, M&T Books, 1991.
  31. */
  32.  
  33. /* store a value in the window extra bytes of a window */
  34.  
  35. #define SET_WND_EXTRABYTES(hWnd, Struct, Member, Value) \
  36.     ((sizeof (((Struct FAR *)0)->Member) == sizeof (DWORD)) ? \
  37.     SetWindowLong (hWnd, offsetof (Struct, Member), Value) : \
  38.     SetWindowWord (hWnd, offsetof (Struct, Member), (WORD) Value))
  39.  
  40. /* store a value in the class extra bytes of a class */
  41.         
  42. #define SET_CLS_EXTRABYTES(hWnd, Struct, Member, Value) \
  43.     ((sizeof (((Struct FAR *)0)->Member) == sizeof (DWORD)) ? \
  44.     SetClassLong (hWnd, offsetof (Struct, Member), Value) : \
  45.     SetClassWord (hWnd, offsetof (Struct, Member), (WORD) Value))
  46.  
  47. /* retrieve a value from a window's extra bytes */
  48.         
  49. #define GET_WND_EXTRABYTES(hWnd, Struct, Member) \
  50.     ((sizeof (((Struct FAR *)0)->Member) == sizeof (DWORD)) ? \
  51.     GetWindowLong (hWnd, offsetof (Struct, Member)) : \
  52.     GetWindowWord (hWnd, offsetof (Struct, Member)))
  53.  
  54. /* retrieve a value from a class' extra bytes */
  55.         
  56. #define GET_CLS_EXTRABYTES(hWnd, Struct, Member) \
  57.     ((sizeof (((Struct FAR *)0)->Member) == sizeof (DWORD)) ? \
  58.     GetClassLong (hWnd, offsetof (Struct, Member)) : \
  59.     GetClassWord (hWnd, offsetof (Struct, Member)))
  60.  
  61. /* delay in seconds */
  62.  
  63. #define WAIT_MSECS(msecs) \
  64.     { \
  65.         DWORD dwTime = GetTickCount (); \
  66.         while (GetTickCount () < dwTime + msecs); \
  67.     }
  68.