home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / OWLSRC.PAK / ANIMCTRL.CPP next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  2.6 KB  |  99 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1995, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.10  $
  6. //
  7. // Implementation of the TAnimateCtrl class
  8. //----------------------------------------------------------------------------
  9. #include <owl/pch.h>
  10. #if !defined(OWL_ANIMCTRL_H)
  11. # include <owl/animctrl.h>
  12. #endif
  13.  
  14. OWL_DIAGINFO;
  15. DIAG_DECLARE_GROUP(OwlCommCtrl);
  16.  
  17. // Constructor for a TAnimateCtrl to be associated with a new underlying
  18. // control.
  19. //
  20. TAnimateCtrl::TAnimateCtrl(TWindow* parent, int id, int x, int y, int w, int h,
  21.                            TModule* module)
  22. :
  23.  TControl(parent, id, "", x, y, w, h, module)
  24. {
  25.   if (!TCommCtrl::IsAvailable())
  26.     throw TXCommCtrl();
  27.   Attr.Style = WS_CHILD | WS_VISIBLE | ACS_CENTER | ACS_TRANSPARENT;
  28.   TRACEX(OwlCommCtrl, OWL_CDLEVEL, "TAnimateCtrl constructed @" << (void*)this);
  29. }
  30.  
  31. // Constructor to alias a control defined in a dialog resource
  32. //
  33. TAnimateCtrl::TAnimateCtrl(TWindow* parent, int resourceId, TModule* module)
  34. :
  35.  TControl(parent, resourceId, module)
  36. {
  37.   if (!TCommCtrl::IsAvailable())
  38.     throw TXCommCtrl();
  39.   TRACEX(OwlCommCtrl, OWL_CDLEVEL, "TAnimateCtrl constructed @" << (void*)this);
  40. }
  41.  
  42. // Destructor
  43. //
  44. TAnimateCtrl::~TAnimateCtrl()
  45. {
  46.   TRACEX(OwlCommCtrl, OWL_CDLEVEL, "TAnimateCtrl deleted @" << (void*)this);
  47. }
  48.  
  49. // Opens an .AVI file and displays the first frame.
  50. // The 'res' parameter may be a resourceId if the .AVI is from a resource.
  51. // It may also be a full path of an .AVI file.
  52. // Use NULL (0) as 'res' to close any previously opened .AVI file.
  53. //
  54. bool
  55. TAnimateCtrl::Open(char far* res)
  56. {
  57.   return SendMessage(ACM_OPEN, 0, TParam2(res)) != 0;
  58. }
  59.  
  60. // Plays the .AVI file from frame index 'start' to frame index 'end'.
  61. // The 'repeat' parameter is the number of times to play the frames.
  62. // Use -1 for repeat to play indefinitely.
  63. // NOTE: The control plays the clip in the backgroud while the 
  64. //       current thread continues executing.
  65. //
  66. bool
  67. TAnimateCtrl::Play(uint16 start, uint16 end, uint repeat)
  68. {
  69.   return SendMessage(ACM_PLAY, repeat, MkUint32(start, end)) != 0;
  70. }
  71.  
  72. // Seek to frame index 'frame'. The value is zero-based and must not
  73. // exceed 65,536.
  74. //
  75. bool
  76. TAnimateCtrl::Seek(uint16 frame)
  77. {
  78.   return Play(frame, frame, 0);
  79. }
  80.  
  81. // Stops playing the current AVI file.
  82. //
  83. void
  84. TAnimateCtrl::Stop()
  85. {
  86.   SendMessage(ACM_STOP);
  87. }
  88.  
  89. //
  90. // Returns the predefined class registered by the Common Control library
  91. // for the Animation control.
  92. //
  93. char far*
  94. TAnimateCtrl::GetClassName()
  95. {
  96.   return ANIMATE_CLASS;
  97. }
  98.  
  99.