home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 2000 May / PCP163A.iso / Runimage / Cbuilder4 / Examples / DDraw / DDraw1C / MAIN.H < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-26  |  1.9 KB  |  75 lines

  1. #ifndef MainH
  2. #define MainH
  3. #include <Classes.hpp>
  4. #include <Controls.hpp>
  5. #include <StdCtrls.hpp>
  6. #include <Forms.hpp>
  7. #include <Menus.hpp>
  8. #include <ExtCtrls.hpp>
  9.  
  10. #define WM_RUNAPP WM_USER
  11. #define CIRCLETYPE 0
  12. #define RECTTYPE 1
  13.  
  14. class TDrawShape : public TObject
  15. {
  16. private:
  17.   int FX;
  18.   int FY;
  19.   int FX1;
  20.   int FY1;
  21.   int FMoveValX;
  22.   int FMoveValY;
  23.   int FShapeType;
  24.   RECT FPrevRect, FPrevRect2;
  25.   TColor FColor;
  26.   RECT __fastcall GetRect()
  27.   {
  28.     return Rect(FX,FY,FX1,FY1);
  29.   }
  30.   void __fastcall SetRect(RECT R)
  31.   {
  32.     FX = R.left; FY = R.top; FX1 = R.right; FY1 = R.bottom;
  33.   }
  34. public:
  35.   __fastcall TDrawShape(int ValX, int ValY) { FMoveValX = ValX; FMoveValY = ValY; }
  36.   __fastcall TDrawShape(int ValX, int ValY, int X, int Y, int AType, TColor AColor);
  37.   void Move();
  38.   void Draw(HDC &DC);
  39.   __property RECT ShapeRect={read=GetRect, write=SetRect};
  40.   __property int ShapeType={read=FShapeType, write=FShapeType};
  41.   __property TColor Color={read=FColor, write=FColor};
  42. };
  43.  
  44. class TForm1 : public TForm
  45. {
  46. __published:
  47.   void __fastcall FormDestroy(TObject *Sender);
  48.   void __fastcall FormKeyDown(TObject *Sender, WORD &Key,
  49.     TShiftState Shift);
  50.   void __fastcall FormPaint(TObject *Sender);
  51. private:
  52.   LPDIRECTDRAW            lpDD;           // DirectDraw object
  53.   LPDIRECTDRAWSURFACE     lpDDSPrimary;   // DirectDraw primary surface
  54.   LPDIRECTDRAWSURFACE     lpDDSBack;      // DirectDraw back surface
  55.   BOOL FActive;        // is application active?
  56.   BYTE FPhase;
  57.   RECT FShapeRect;
  58.   TList *FShapeList;
  59.   int FValueAdd;
  60.   void BuildList();
  61.   void DrawShape(HDC &DC);
  62.   void PerformAction();
  63.   MESSAGE void Run(TMessage &Message);
  64.   void __fastcall Start();
  65. public:
  66.   __fastcall TForm1(TComponent* Owner);
  67. BEGIN_MESSAGE_MAP
  68.   MESSAGE_HANDLER(WM_RUNAPP, TMessage, Run);
  69. END_MESSAGE_MAP(TForm);
  70. };
  71.  
  72. extern TForm1 *Form1;
  73.  
  74. #endif
  75.