home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual dBase v5.5 / CUSTOM.PAK / AVIPANEL.CC next >
Encoding:
C/C++ Source or Header  |  1995-07-18  |  10.4 KB  |  321 lines

  1. *****************************************************************************
  2. *  PROGRAM:      AVIPanel.cc
  3. *
  4. *  WRITTEN BY:   Borland Samples Group
  5. *
  6. *  DATE:         5/95
  7. *
  8. *  UPDATED:      6/95
  9. *
  10. *  REVISION:     $Revision:   1.1  $
  11. *
  12. *  VERSION:      Visual dBASE
  13. *
  14. *
  15. *  DESCRIPTION:  This is a Custom Control file containing a Custom Class
  16. *                derived from the built in PAINTBOX Class. The Custom Class,
  17. *                "AVIPanel" is a display panel, along with all the necessary
  18. *                methods, for displaying a Video for Windows AVI file. This
  19. *                requires Microsoft's Video for Windows to be installed.
  20. *
  21. *  USAGE:        SET PROCEDURE TO AVIPANEL.CC ADDITIVE
  22. *
  23. *                NEW syntax:     f = NEW form()
  24. *                                x = NEW AVIPanel(f,"VideoPanel")
  25. *                                f.Open()
  26. *                                f.VideoPanel.OpenAVI()
  27. *                                f.VideoPanel.PlayAVI()
  28. *
  29. *                DEFINE syntax:  DEFINE FORM f
  30. *                                DEFINE AVIPanel MyVideoPanel OF f
  31. *                                OPEN FORM f
  32. *
  33. *                FORMS DESIGNER: Use "File | Set Up Custom Controls" menu to
  34. *                                install the AVIPANEL.CC file, then select
  35. *                                the AVIPANEL control "Custom" page of the
  36. *                                Control Palette.
  37. *
  38. *                ONCE RUNNING:   Right click the black panel to see it run.
  39. *
  40. *                METHODS LIST:
  41. *                             AVIPanel_OnOpen           && Sets up control
  42. *                             AVIPanel_OnRightMouseUp   && Invokes Menu
  43. *                             OpenAVI                   && Opens AVI file
  44. *                             PlayAVI                   && Plays video file
  45. *                             PauseAVI                  && Pauses AVI file
  46. *                             RewindAVI                 && Rewinds AVI file
  47. *                             StopAVI                   && Stops AVI file
  48. *                             CloseAVI                  && Closes AVI file
  49. *                             ResizeAVI(AVIWidth, AVIHeight) && Re-size's AVI
  50. *                             MCIExec                   && Execute MCI string
  51. *
  52. *****************************************************************************
  53.  
  54.  
  55. *****************************************************************************
  56. *****************************************************************************
  57. CLASS AVIPanel(FormObj,Name) OF PaintBox(FormObj,Name) Custom
  58. *****************************************************************************
  59.  
  60.    protect VideoFile, ColorNormal
  61.  
  62.    this.Height = 7.09   && 120 Pixels (convert @ 16.93)
  63.    this.Width = 26.83   && 160 Pixels (convert @ 5.96)
  64.    this.Left = 8
  65.    this.Top = 1.5
  66.    this.ColorNormal = "W+/N"
  67.    this.OnRightMouseUp = CLASS::AVIPanel_OnRightMouseUp
  68.    this.PageNo = 1
  69.    this.VideoFile = ""
  70.    this.AVI_Clip = FUNIQUE()
  71.    this.Size = "160 120"        && Initial AVI frame size in pixels
  72.    this.OnOpen = CLASS::AVIPanel_ONOPEN
  73.    this.OnClose = CLASS::CloseAVI
  74.  
  75.  
  76.    ****************************************************************************
  77.    Procedure AVIPanel_OnOpen
  78.  
  79.    * MCI execution function and SpeedMenu
  80.    ****************************************************************************
  81.  
  82.    extern CINT MciExecute(CSTRING) MMSYSTEM.DLL && MultiMedia extensions
  83.    if .not. type("this.Parent.AVIPanelMenu") = "O"
  84.       new AVIPanelPopUp(this.Parent, "AVIPanelMenu")
  85.    endif
  86.  
  87.  
  88.    ****************************************************************************
  89.    Procedure OpenAVI(VideoFileName)
  90.  
  91.    * Opens optionally named AVI file
  92.    ****************************************************************************
  93.  
  94.    if len(this.VideoFile) > 0
  95.       this.CloseAVI()
  96.    endif
  97.    if pcount() = 0
  98.       this.VideoFile = GetFile("*.AVI", "Select a Video File (*.AVI)")
  99.    else
  100.       this.VideoFile = VideoFileName
  101.    endif
  102.    this.MCIStr = "OPEN " + this.VideoFile + ;
  103.      " TYPE AVIVIDEO ALIAS " + this.AVI_Clip + " STYLE child PARENT" + STR(this.hWnd)
  104.    this.MCIExec()
  105.    this.MCIStr = "PUT " + this.AVI_Clip + " WINDOW AT 0 0 " + this.Size
  106.    this.MCIExec()
  107.  
  108.  
  109.    ****************************************************************************
  110.    Procedure PlayAVI
  111.  
  112.    * Plays selected AVI
  113.    ****************************************************************************
  114.  
  115.    this.MCIStr = "PLAY " + this.AVI_Clip
  116.    this.MCIExec()
  117.  
  118.  
  119.    ****************************************************************************
  120.    Procedure PauseAVI
  121.  
  122.    * Pauses video display
  123.    ****************************************************************************
  124.  
  125.    this.MCIStr = "PAUSE " + this.AVI_Clip
  126.    this.MCIExec()
  127.  
  128.  
  129.    ****************************************************************************
  130.    Procedure RewindAVI
  131.  
  132.    * Rewinds current AVI to beginning
  133.    ****************************************************************************
  134.    local VideoToRewind
  135.  
  136.    VideoToRewind = this.VideoFile
  137.    if len(this.VideoFile) > 0
  138.       this.CloseAVI()
  139.       this.VideoFile = VideoToRewind
  140.       this.MCIStr = "OPEN " + this.VideoFile + ;
  141.         " TYPE AVIVIDEO ALIAS " + this.AVI_Clip + " STYLE child PARENT" + STR(this.hWnd)
  142.       this.MCIExec()
  143.       this.MCIStr = "PUT " + this.AVI_Clip + " WINDOW AT 0 0 " + this.Size
  144.       this.MCIExec()
  145.    endif
  146.  
  147.  
  148.    ****************************************************************************
  149.    Procedure StopAVI
  150.  
  151.    * Stops playing current AVI
  152.    ****************************************************************************
  153.  
  154.    this.MCIStr = "STOP " + this.AVI_Clip
  155.    this.MCIExec()
  156.  
  157.  
  158.    ****************************************************************************
  159.    Procedure CloseAVI
  160.  
  161.    * Closes current AVI
  162.    ****************************************************************************
  163.  
  164.    this.MCIStr = "CLOSE " + this.AVI_Clip
  165.    this.MCIExec()
  166.    this.VideoFile = ""
  167.  
  168.  
  169.    ****************************************************************************
  170.    Procedure ResizeAVI(AVIWidth, AVIHeight, ReSizeControl)
  171.  
  172.    * Resizes AVI file to in pixels, optionally resizes control the AVI
  173.    * is displaying on via 3rd parameter (logical)
  174.    ****************************************************************************
  175.  
  176.    if ReSizeControl
  177.       this.Height = AVIHeight/16.93
  178.       this.Width = AVIWidth/5.96
  179.    endif
  180.    AVIHeight = ltrim(rtrim(str(AVIHeight)))
  181.    AVIWidth = ltrim(rtrim(str(AVIWidth)))
  182.    this.Size = AVIWidth + " " + AVIHeight
  183.    this.MCIStr = "PUT " + this.AVI_Clip + " WINDOW AT 0 0 " + this.Size
  184.    this.MCIExec()
  185.  
  186.  
  187.    ****************************************************************************
  188.    Procedure MCIExec
  189.  
  190.    * Executes MCI command
  191.    ****************************************************************************
  192.  
  193.    if len(this.VideoFile) > 0
  194.       this.RetValue = MciExecute(this.MCIStr)
  195.    endif
  196.  
  197.  
  198.    ****************************************************************************
  199.    Procedure AVIPanel_OnRightMouseUp(flags, col, row)
  200.  
  201.    * Invokes the SpeedMenu that has basic UI for control
  202.    ****************************************************************************
  203.  
  204.    col = col + this.Left
  205.    row = row + this.Top
  206.    form.AVIPanelMenu.Top = row
  207.    form.AVIPanelMenu.Left = col
  208.    form.AVIPanelMenu.Active = this
  209.    form.AVIPanelMenu.Open()
  210.  
  211. ENDCLASS
  212.  
  213.  
  214. *******************************************************************************
  215. *******************************************************************************
  216. CLASS AVIPanelPopUp(FormObj, PopupName) OF POPUP(FormObj, PopupName)
  217.  
  218. * This is the CLASS definition for the AVI controls SpeedMenu
  219. *******************************************************************************
  220.  
  221.    this.TrackRight = .T.
  222.    this.Left = 0
  223.    this.Top = 0
  224.  
  225.    DEFINE MENU OPEN_VIDEO OF THIS;
  226.        PROPERTY;
  227.          Text "Open Video",;
  228.          OnClick CLASS::OPEN_VIDEO_ONCLICK
  229.  
  230.    DEFINE MENU Separator1 OF THIS;
  231.        PROPERTY;
  232.          Text "",;
  233.          Separator .T.
  234.  
  235.    DEFINE MENU PLAY_VIDEO OF THIS;
  236.        PROPERTY;
  237.          Text "Play Video",;
  238.          OnClick CLASS::PLAY_VIDEO_ONCLICK
  239.  
  240.    DEFINE MENU PAUSE_VIDEO OF THIS;
  241.        PROPERTY;
  242.          Text "Pause Video",;
  243.          OnClick CLASS::PAUSE_VIDEO_ONCLICK
  244.  
  245.    DEFINE MENU STOP_VIDEO OF THIS;
  246.        PROPERTY;
  247.          Text "Stop Video",;
  248.          OnClick CLASS::STOP_VIDEO_ONCLICK
  249.  
  250.    DEFINE MENU REWIND_VIDEO OF THIS;
  251.        PROPERTY;
  252.          Text "Rewind Video",;
  253.          OnClick CLASS::REWIND_VIDEO_ONCLICK
  254.  
  255.    DEFINE MENU Separator2 OF THIS;
  256.        PROPERTY;
  257.          Text "",;
  258.          Separator .T.
  259.  
  260.    DEFINE MENU CLOSE_VIDEO OF THIS;
  261.        PROPERTY;
  262.          Text "Close Video",;
  263.          OnClick CLASS::CLOSE_VIDEO_ONCLICK
  264.  
  265.  
  266.    ****************************************************************************
  267.    Procedure OPEN_VIDEO_OnClick
  268.  
  269.    * Opens AVI
  270.    ****************************************************************************
  271.  
  272.    form.AVIPanelMenu.Active.OpenAVI()
  273.  
  274.  
  275.    ****************************************************************************
  276.    Procedure PLAY_VIDEO_OnClick
  277.  
  278.    * Plays AVI
  279.    ****************************************************************************
  280.  
  281.    form.AVIPanelMenu.Active.PlayAVI()
  282.  
  283.  
  284.    ****************************************************************************
  285.    Procedure PAUSE_VIDEO_OnClick
  286.  
  287.    * Pauses AVI
  288.    ****************************************************************************
  289.  
  290.    form.AVIPanelMenu.Active.PauseAVI()
  291.  
  292.  
  293.    ****************************************************************************
  294.    Procedure STOP_VIDEO_OnClick
  295.  
  296.    * Stops AVI
  297.    ****************************************************************************
  298.  
  299.    form.AVIPanelMenu.Active.StopAVI()
  300.  
  301.  
  302.    ****************************************************************************
  303.    Procedure REWIND_VIDEO_OnClick
  304.  
  305.    * Rewinds AVI
  306.    ****************************************************************************
  307.  
  308.    form.AVIPanelMenu.Active.RewindAVI()
  309.  
  310.  
  311.    ****************************************************************************
  312.    Procedure CLOSE_VIDEO_OnClick
  313.  
  314.    * Closes AVI
  315.    ****************************************************************************
  316.  
  317.    form.AVIPanelMenu.Active.CloseAVI()
  318.  
  319.  
  320. ENDCLASS
  321.