SPINCUBE.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:5k
源码类别:

Windows编程

开发平台:

Visual C++

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