home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winui / controls / spincube / spincube.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-29  |  5.2 KB  |  125 lines

  1. /******************************************************************************\
  2. *
  3. *                                  SPINCUBE.H
  4. *
  5. \******************************************************************************/
  6.  
  7. #include <custcntl.h>
  8.  
  9.  
  10.  
  11. /******************************************************************************\
  12. *                               SYMBOLIC CONSTANTS
  13. \******************************************************************************/
  14.  
  15. #define SPINCUBECLASS           "Spincube"
  16. #define SPINCUBEDESCRIPTION     "An animated control"
  17. #define SPINCUBEDEFAULTTEXT     ":-)"
  18.  
  19. #define CCHSTYLE                20  // size of style string, i.e. "SS_ERASE"
  20.  
  21. #define NUM_SPINCUBE_STYLES     2
  22.  
  23. #define SS_ERASE                0x0001  // spincube window styles
  24. #define SS_INMOTION             0x0002
  25.  
  26.  
  27. #define SPINCUBE_EXTRA          4   // number of extra bytes for spincube class
  28.  
  29. #define SPIN_EVENT              1   // timer event id to repaint control
  30. #ifdef _ALPHA_
  31. #define SPIN_INTERVAL           0   // milliseconds between repaints. what
  32.                                     //   would be really cool is a way to
  33.                                     //   dynamically adjust the interval-
  34.                                     //   on real fast machines we might
  35.                                     //   almost be able to get decent-looking
  36.                                     //   animation! :)
  37.  
  38. #else
  39. #define SPIN_INTERVAL           75  // milliseconds between repaints. what
  40.                                     //   would be really cool is a way to
  41.                                     //   dynamically adjust the interval-
  42.                                     //   on real fast machines we might
  43.                                     //   almost be able to get decent-looking
  44.                                     //   animation! :)
  45.  
  46. #endif
  47. #define DID_ERASE               101 // dialog control id's
  48. #define DID_INMOTION            102
  49. #define DID_OK                  103
  50.  
  51. #define GWL_SPINCUBEDATA        0   // offset of control's instance data
  52.  
  53. #define SPINCUBE_REPAINT_BKGND  0x00000001
  54.  
  55. #define DO_ERASE(hwnd)          GetWindowLong(hwnd,GWL_STYLE) & SS_ERASE \
  56.                                            ? TRUE : FALSE
  57.  
  58. #define IN_MOTION(hwnd)         GetWindowLong(hwnd,GWL_STYLE) & SS_INMOTION \
  59.                                            ? TRUE : FALSE
  60.  
  61. #define REPAINT_BKGND(pSCI)     pSCI->iOptions&SPINCUBE_REPAINT_BKGND \
  62.                                            ? TRUE : FALSE
  63.  
  64. #define IDS_REGCLASSFAIL      16
  65. #define IDS_UNREGFAIL         17
  66. #define IDS_DLGBOXFAIL        18
  67. #define IDS_ALLOCFAIL         19
  68. #define IDS_CREATEDCFAIL      20
  69. #define IDS_CREATEBITMAPFAIL  21
  70.  
  71.  
  72.  
  73. /******************************************************************************\
  74. *                                    TYPEDEFs
  75. \******************************************************************************/
  76.  
  77. typedef struct
  78. {
  79.   HDC      hdcCompat;               // the DC that will contain our off-screen
  80.                                     //   image
  81.   HBITMAP  hbmSave;                 // Save previous selected bitmap
  82.   HBITMAP  hbmCompat;               // The bitmap that will contain the actual
  83.                                     //   image, i.e. we will always do our
  84.                                     //   drawing on this bmp & then blt the
  85.                                     //   result to the screen.
  86.  
  87.   float    fCurrentXRotation;       // Angle (in radians) to rotate cube about
  88.   float    fCurrentYRotation;       //   x, y, z axis
  89.   float    fCurrentZRotation;
  90.  
  91.   float    fCurrentXRotationInc;    // Amount to inc rotation angle each
  92.   float    fCurrentYRotationInc;    //   time we repaint (and are in motion)
  93.   float    fCurrentZRotationInc;
  94.  
  95.   int      iCurrentXTranslation;    // Distance (in pels) to translate cube
  96.   int      iCurrentYTranslation;
  97.   int      iCurrentZTranslation;
  98.  
  99.   int      iCurrentXTranslationInc; // Amount to inc translation distance each
  100.   int      iCurrentYTranslationInc; //   time we repaint (and are in motion)
  101.   int      iCurrentZTranslationInc;
  102.  
  103.   RECT     rcCubeBoundary;          // Bounding rectangle (in 2D) of the last
  104.                                     //   cube drawn.  We invalidate only this
  105.                                     //   region when we're doing animation
  106.                                     //   and get the WM_TIMER- it's alot more
  107.                                     //   efficient that invalidating the whole
  108.                                     //   control (there's less screen flashing.
  109.  
  110.   int      iOptions;                // Contains the current options for this
  111.                                     //   ctrl, i.e. erase background.
  112.  
  113. } SPINCUBEINFO, *PSPINCUBEINFO;
  114.  
  115.  
  116.  
  117. /******************************************************************************\
  118. *                                FUNCTION PROTOTYPES
  119. \******************************************************************************/
  120.  
  121. INT     CALLBACK SpincubeSizeToText (DWORD, DWORD, HFONT,  LPSTR);
  122. BOOL    CALLBACK SpincubeStyle      (HWND,  LPCCSTYLE);
  123. LRESULT CALLBACK SpincubeWndProc    (HWND,  UINT,  WPARAM, LPARAM);
  124. LRESULT CALLBACK SpincubeDlgProc    (HWND,  UINT,  WPARAM, LPARAM);
  125.