home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / amovie / sdk / vbfix / ocxvb01.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-06-28  |  19.0 KB  |  542 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMain 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "ActiveMovie OCX Sample"
  5.    ClientHeight    =   2910
  6.    ClientLeft      =   3435
  7.    ClientTop       =   2295
  8.    ClientWidth     =   5370
  9.    Height          =   3600
  10.    Icon            =   "ocxvb01.frx":0000
  11.    Left            =   3375
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   2910
  16.    ScaleWidth      =   5370
  17.    ShowInTaskbar   =   0   'False
  18.    Top             =   1665
  19.    Width           =   5490
  20.    Begin VB.Frame frmImageSize 
  21.       Caption         =   "Change Image Size"
  22.       Enabled         =   0   'False
  23.       Height          =   2292
  24.       Left            =   2880
  25.       TabIndex        =   9
  26.       Top             =   120
  27.       Width           =   2292
  28.       Begin VB.OptionButton obOneHalfScreen 
  29.          Caption         =   "One Half Screen"
  30.          Height          =   255
  31.          Left            =   240
  32.          TabIndex        =   14
  33.          Top             =   1800
  34.          Width           =   1935
  35.       End
  36.       Begin VB.OptionButton obOneFourthScreen 
  37.          Caption         =   "One Fourth Screen"
  38.          Height          =   255
  39.          Left            =   240
  40.          TabIndex        =   13
  41.          Top             =   1440
  42.          Width           =   1935
  43.       End
  44.       Begin VB.OptionButton obOneSixteenthScreen 
  45.          Caption         =   "One Sixteenth Screen"
  46.          Height          =   255
  47.          Left            =   240
  48.          TabIndex        =   12
  49.          Top             =   1080
  50.          Width           =   1935
  51.       End
  52.       Begin VB.OptionButton obDoubleOriginal 
  53.          Caption         =   "Double Original Size"
  54.          Height          =   255
  55.          Left            =   240
  56.          TabIndex        =   11
  57.          Top             =   720
  58.          Width           =   1935
  59.       End
  60.       Begin VB.OptionButton obOriginal 
  61.          Caption         =   "Original Size"
  62.          Height          =   255
  63.          Left            =   240
  64.          TabIndex        =   10
  65.          Top             =   360
  66.          Width           =   1815
  67.       End
  68.    End
  69.    Begin VB.Frame frmPlaybackRate 
  70.       Caption         =   "Change Playback Rate"
  71.       Height          =   1212
  72.       Left            =   240
  73.       TabIndex        =   4
  74.       Top             =   1200
  75.       Width           =   2412
  76.       Begin VB.Label Label3 
  77.          Alignment       =   2  'Center
  78.          Caption         =   "1.5"
  79.          Height          =   252
  80.          Left            =   1860
  81.          TabIndex        =   8
  82.          Top             =   840
  83.          Width           =   252
  84.       End
  85.       Begin VB.Label Label2 
  86.          Alignment       =   2  'Center
  87.          Caption         =   "1.0"
  88.          Height          =   252
  89.          Left            =   1020
  90.          TabIndex        =   7
  91.          Top             =   840
  92.          Width           =   372
  93.       End
  94.       Begin VB.Label Label1 
  95.          Alignment       =   2  'Center
  96.          Caption         =   "0.5"
  97.          Height          =   252
  98.          Left            =   240
  99.          TabIndex        =   6
  100.          Top             =   840
  101.          Width           =   372
  102.       End
  103.       Begin ComctlLib.Slider Slider1 
  104.          Height          =   492
  105.          Left            =   240
  106.          TabIndex        =   5
  107.          Top             =   240
  108.          Width           =   1932
  109.          _Version        =   65536
  110.          _ExtentX        =   3413
  111.          _ExtentY        =   873
  112.          _StockProps     =   64
  113.          Enabled         =   0   'False
  114.          LargeChange     =   1
  115.          TickStyle       =   2
  116.       End
  117.    End
  118.    Begin VB.Frame frmChangeFrames 
  119.       Caption         =   "Change Current Position"
  120.       Height          =   972
  121.       Left            =   240
  122.       TabIndex        =   1
  123.       Top             =   120
  124.       Width           =   2412
  125.       Begin VB.CommandButton cmdNextFrame 
  126.          Caption         =   "&>>"
  127.          Enabled         =   0   'False
  128.          Height          =   372
  129.          Left            =   1320
  130.          TabIndex        =   3
  131.          Top             =   360
  132.          Width           =   852
  133.       End
  134.       Begin VB.CommandButton cmdPreviousFrame 
  135.          Caption         =   "&<<"
  136.          Enabled         =   0   'False
  137.          Height          =   372
  138.          Left            =   240
  139.          TabIndex        =   2
  140.          Top             =   360
  141.          Width           =   852
  142.       End
  143.    End
  144.    Begin ComctlLib.StatusBar StatusBar1 
  145.       Align           =   2  'Align Bottom
  146.       Height          =   408
  147.       Left            =   0
  148.       TabIndex        =   0
  149.       Top             =   2508
  150.       Width           =   5364
  151.       _Version        =   65536
  152.       _ExtentX        =   9462
  153.       _ExtentY        =   720
  154.       _StockProps     =   68
  155.       AlignSet        =   -1  'True
  156.       SimpleText      =   ""
  157.       NumPanels       =   3
  158.       i1              =   "ocxvb01.frx":030A
  159.       i2              =   "ocxvb01.frx":0416
  160.       i3              =   "ocxvb01.frx":0522
  161.    End
  162.    Begin MSComDlg.CommonDialog CommonDialog1 
  163.       Left            =   240
  164.       Top             =   5880
  165.       _Version        =   65536
  166.       _ExtentX        =   847
  167.       _ExtentY        =   847
  168.       _StockProps     =   0
  169.    End
  170.    Begin VB.Menu mnu_File 
  171.       Caption         =   "&File"
  172.       Begin VB.Menu mnu_File_Open 
  173.          Caption         =   "&Open"
  174.       End
  175.       Begin VB.Menu sep1 
  176.          Caption         =   "-"
  177.       End
  178.       Begin VB.Menu mnu_File_Run 
  179.          Caption         =   "&Run"
  180.       End
  181.       Begin VB.Menu mnu_File_Pause 
  182.          Caption         =   "&Pause"
  183.       End
  184.       Begin VB.Menu mnu_File_Stop 
  185.          Caption         =   "&Stop"
  186.       End
  187.       Begin VB.Menu sep2 
  188.          Caption         =   "-"
  189.       End
  190.       Begin VB.Menu mnu_File_Exit 
  191.          Caption         =   "E&xit"
  192.       End
  193.    End
  194.    Begin VB.Menu mnu_View 
  195.       Caption         =   "&View"
  196.       Begin VB.Menu mnu_View_DisplayPanel 
  197.          Caption         =   "&Display Panel"
  198.          Checked         =   -1  'True
  199.       End
  200.       Begin VB.Menu sep4 
  201.          Caption         =   "-"
  202.       End
  203.       Begin VB.Menu mnu_View_ControlPanel 
  204.          Caption         =   "&Control Panel"
  205.          Checked         =   -1  'True
  206.       End
  207.       Begin VB.Menu mnu_View_PositionControls 
  208.          Caption         =   "&Position Controls"
  209.          Checked         =   -1  'True
  210.       End
  211.       Begin VB.Menu mnu_View_SelectionControls 
  212.          Caption         =   "&Selection Controls"
  213.          Checked         =   -1  'True
  214.       End
  215.       Begin VB.Menu mnu_View_Tracker 
  216.          Caption         =   "&Tracker"
  217.          Checked         =   -1  'True
  218.       End
  219.    End
  220.    Begin VB.Menu mnu_Enable 
  221.       Caption         =   "E&nable"
  222.       Begin VB.Menu mnu_Enable_PositionControls 
  223.          Caption         =   "&Position Controls"
  224.          Checked         =   -1  'True
  225.       End
  226.       Begin VB.Menu mnu_Enable_SelectionControls 
  227.          Caption         =   "&Selection Controls"
  228.          Checked         =   -1  'True
  229.       End
  230.       Begin VB.Menu mnu_Enable_Tracker 
  231.          Caption         =   "&Tracker"
  232.          Checked         =   -1  'True
  233.       End
  234.    End
  235.    Begin VB.Menu mnu_Options 
  236.       Caption         =   "&Options"
  237.       Begin VB.Menu mnu_Options_AutoRewind 
  238.          Caption         =   "Auto &Rewind"
  239.          Checked         =   -1  'True
  240.       End
  241.       Begin VB.Menu mnu_Options_DisplayTime 
  242.          Caption         =   "Display &Time"
  243.          Checked         =   -1  'True
  244.       End
  245.    End
  246. Attribute VB_Name = "frmMain"
  247. Attribute VB_Creatable = False
  248. Attribute VB_Exposed = False
  249. ' ActiveMovie Control Sample
  250. ' Copyright (c) 1996 Microsoft Corporation
  251. ' All Rights Reserved.
  252. Private Sub cmdNextFrame_Click()
  253.     If ((frmViewer.ActiveMovie1.CurrentPosition + 0.1) <= frmViewer.ActiveMovie1.Duration) Then
  254.         frmViewer.ActiveMovie1.CurrentPosition = frmViewer.ActiveMovie1.CurrentPosition + 0.1
  255.     End If
  256. End Sub
  257. Private Sub cmdPreviousFrame_Click()
  258.     If ((frmViewer.ActiveMovie1.CurrentPosition - 0.1) >= 0) Then
  259.         frmViewer.ActiveMovie1.CurrentPosition = frmViewer.ActiveMovie1.CurrentPosition - 0.1
  260.     End If
  261. End Sub
  262. Private Sub Form_Load()
  263.     ' ActiveMovie Control Sample Code
  264.     ' Copyright (c) 1996 Microsoft Corporation
  265.     ' All Rights Reserved
  266.     ' This sample demonstrates the ActiveMovie Control.
  267.     ' It contains the following controls:
  268.     '
  269.     '   The ActiveMovie control (in its own form).
  270.     '   A status bar control.
  271.     '   The common dialogs control.
  272.     '   Two buttons that allow you to step through the stream.
  273.     '   Option buttons that let you select the stream size.
  274.     '   A slider that lets you change the playback rate.
  275.     ' The main form, frmMain, contains several menus that
  276.     ' control various ActiveMovie controls.
  277.     ' When events are enabled, a global counter is used to
  278.     ' keep a running account of each ActiveMovie control event,
  279.     ' and the value is displayed in the status control.
  280.     ' Initialize control properties and set menu items to match.
  281.     Slider1.Value = 5   ' Right in the middle.
  282.     ' Default value for ActiveMovie1.Rate = 1.0
  283.     ' Use default value.
  284.     obOriginal.Value = True
  285.     With frmViewer.ActiveMovie1
  286.         ' Display current position in time, rather than frames.
  287.         .DisplayMode = amvTime
  288.         mnu_Options_DisplayTime.Checked = True
  289.         
  290.         ' Show the display panel.
  291.         .ShowDisplay = True
  292.         mnu_View_DisplayPanel.Checked = True
  293.         
  294.         ' Show the control panel and all other controls.
  295.         .ShowControls = True
  296.         mnu_View_ControlPanel.Checked = True
  297.         .ShowPositionControls = False
  298.         mnu_View_PositionControls.Checked = False
  299.         .ShowSelectionControls = False
  300.         mnu_View_SelectionControls.Checked = False
  301.         .ShowTracker = True
  302.         mnu_View_Tracker.Checked = True
  303.         
  304.         ' Enable the sub-controls on the control panel.
  305.         .EnablePositionControls = False
  306.         mnu_Enable_PositionControls.Checked = False
  307.         .EnableSelectionControls = False
  308.         mnu_Enable_SelectionControls.Checked = False
  309.         .EnableTracker = False
  310.         mnu_Enable_Tracker.Checked = False
  311.         
  312.         ' Set AutoRewind.
  313.         .AutoRewind = True
  314.         mnu_Options_AutoRewind = True
  315.     End With
  316. End Sub
  317. Private Sub Form_Unload(Cancel As Integer)
  318.     End ' end program
  319. End Sub
  320. Private Sub mnu_Enable_PositionControls_Click()
  321.     ' Let the user change the prop value from the menu.
  322.     If (mnu_Enable_PositionControls.Checked) Then
  323.         mnu_Enable_PositionControls.Checked = False
  324.         frmViewer.ActiveMovie1.EnablePositionControls = False
  325.     Else
  326.         mnu_Enable_PositionControls.Checked = True
  327.         frmViewer.ActiveMovie1.EnablePositionControls = True
  328.     End If
  329. End Sub
  330. Private Sub mnu_Enable_SelectionControls_Click()
  331.     ' Let the user change the prop value from the menu.
  332.     If (mnu_Enable_SelectionControls.Checked) Then
  333.         mnu_Enable_SelectionControls.Checked = False
  334.         frmViewer.ActiveMovie1.EnableSelectionControls = False
  335.     Else
  336.         mnu_Enable_SelectionControls.Checked = True
  337.         frmViewer.ActiveMovie1.EnableSelectionControls = True
  338.     End If
  339. End Sub
  340. Private Sub mnu_Enable_Tracker_Click()
  341.     ' Let the user change the prop value from the menu.
  342.     If (mnu_Enable_Tracker.Checked) Then
  343.         mnu_Enable_Tracker.Checked = False
  344.         frmViewer.ActiveMovie1.EnableTracker = False
  345.     Else
  346.         mnu_Enable_Tracker.Checked = True
  347.         frmViewer.ActiveMovie1.EnableTracker = True
  348.     End If
  349. End Sub
  350. Private Sub mnu_File_Exit_Click()
  351.     End ' End program.
  352. End Sub
  353. Private Sub mnu_File_Open_Click()
  354.     ' Opens an ActiveMovie file.
  355.     ' Displays Viewer form if successful.
  356.     On Error GoTo err_FileOpen
  357.     CommonDialog1.Filter = "All files (*.*)|*.*|ActiveMovie files (*.mpg;*.mpa;*.mpv;*.mov;*.mpeg;*.enc;*.m1v;*.mp2)|*.mpg;*.mpa;*.mpv;*.mov;*.mpeg;*.enc;*.m1v;*.mp2|ActiveMovie Streaming Format (*.asf)|*.asf|Audio files (.wav)|*.wav|Video for Windows files (.avi)|*.avi"
  358.     CommonDialog1.Flags = 4 'Hide read-only check box
  359.     CommonDialog1.ShowOpen
  360.     ' New file resets playback speed to 1.0
  361.     Slider1.Value = 5   ' right in the middle
  362.     ' Default value for ActiveMovie1.Rate = 1.0
  363.     ' If did not escape...
  364.     If CommonDialog1.filename <> "" Then
  365.         frmViewer.ActiveMovie1.filename = CommonDialog1.filename
  366.         g_FileOpened = True
  367.         g_FileExtension = Right$(CommonDialog1.filename, Len(CommonDialog1.filename) - InStr(CommonDialog1.filename, "."))
  368.     Else
  369.         GoTo err_FileOpen
  370.     End If
  371.     ' Reset controls and menu settings for new file.
  372.     With frmViewer.ActiveMovie1
  373.         .ShowPositionControls = False
  374.         mnu_View_PositionControls.Checked = False
  375.         .ShowSelectionControls = False
  376.         mnu_View_SelectionControls.Checked = False
  377.         .ShowTracker = True
  378.         mnu_View_Tracker.Checked = True
  379.         
  380.         ' Also, enable the sub-controls on the control panel
  381.         .EnablePositionControls = False
  382.         mnu_Enable_PositionControls.Checked = False
  383.         .EnableSelectionControls = False
  384.         mnu_Enable_SelectionControls.Checked = False
  385.         .EnableTracker = False
  386.         mnu_Enable_Tracker.Checked = False
  387.         
  388.         ' Enable change position buttons.
  389.         ' Can't use buttons for .asf files.
  390.         If g_FileExtension = "asf" Then
  391.             cmdPreviousFrame.Enabled = False
  392.             cmdNextFrame.Enabled = False
  393.         Else
  394.             cmdPreviousFrame.Enabled = True
  395.             cmdNextFrame.Enabled = True
  396.             ' Enable playback rate if avi file.
  397.             If g_FileExtension = "avi" Then
  398.                 Slider1.Enabled = True
  399.             End If
  400.         End If
  401.         
  402.         ' Enable frame image size panel.
  403.         frmImageSize.Enabled = True
  404.         
  405.     End With
  406.     Exit Sub
  407. err_FileOpen:
  408.     MsgBox "File open error.", 0, "ActiveMovie OCX Sample"
  409.     Exit Sub
  410. End Sub
  411. Private Sub mnu_File_Pause_Click()
  412.     ' Pauses the current file.
  413.     If g_FileOpened = True Then
  414.         frmViewer.ActiveMovie1.Pause
  415.     End If
  416. End Sub
  417. Private Sub mnu_File_Run_Click()
  418.     ' Starts playing the current file.
  419.     If g_FileOpened = True Then
  420.         frmViewer.ActiveMovie1.Run
  421.         frmViewer.ZOrder 0
  422.     End If
  423. End Sub
  424. Private Sub mnu_File_Stop_Click()
  425.     ' Stops file play.
  426.     If g_FileOpened = True Then
  427.         frmViewer.ActiveMovie1.Stop
  428.     End If
  429. End Sub
  430. Private Sub mnu_Options_AutoRewind_Click()
  431.     ' Toggles the AutoRewind property.
  432.     If (mnu_Options_AutoRewind.Checked) Then
  433.         frmViewer.ActiveMovie1.AutoRewind = False
  434.         mnu_Options_AutoRewind.Checked = False
  435.     Else
  436.         frmViewer.ActiveMovie1.AutoRewind = True
  437.         mnu_Options_AutoRewind.Checked = True
  438.     End If
  439. End Sub
  440. Private Sub mnu_Options_DisplayTime_Click()
  441.     ' Toggles the DisplayMode between time and frames.
  442.     With frmViewer.ActiveMovie1
  443.         If (.DisplayMode = amvTime) Then
  444.             .DisplayMode = amvFrames
  445.             mnu_Options_DisplayTime.Checked = False
  446.         Else
  447.             .DisplayMode = amvTime
  448.             mnu_Options_DisplayTime.Checked = True
  449.         End If
  450.     End With
  451. End Sub
  452. Private Sub mnu_View_ControlPanel_Click()
  453.     ' Toggles the ShowControls property.
  454.     With frmViewer.ActiveMovie1
  455.         If (.AllowHideControls) Then
  456.             If (.ShowControls) Then
  457.                 .ShowControls = False
  458.             Else
  459.                 .ShowControls = True
  460.             End If
  461.             ' Toggle menu check mark.
  462.             mnu_View_ControlPanel.Checked = Not mnu_View_ControlPanel.Checked
  463.         End If
  464.     End With
  465.     ResizeViewer
  466. End Sub
  467. Private Sub mnu_View_DisplayPanel_Click()
  468.     ' Toggles ShowDisplay property.
  469.     With frmViewer.ActiveMovie1
  470.         If (.AllowHideDisplay) Then
  471.             If (.ShowDisplay) Then
  472.                 .ShowDisplay = False
  473.             Else
  474.                 .ShowDisplay = True
  475.             End If
  476.             ' Toggle menu check mark.
  477.             mnu_View_DisplayPanel.Checked = Not mnu_View_DisplayPanel.Checked
  478.         End If
  479.     End With
  480.     ResizeViewer
  481. End Sub
  482. Private Sub mnu_View_PositionControls_Click()
  483.     ' Toggles ShowPositionControls property.
  484.     frmViewer.ActiveMovie1.ShowPositionControls = Not frmViewer.ActiveMovie1.ShowPositionControls
  485.     mnu_View_PositionControls.Checked = Not mnu_View_PositionControls.Checked
  486.     ResizeViewer
  487. End Sub
  488. Private Sub mnu_View_SelectionControls_Click()
  489.     ' Toggles ShowSelectionControls property.
  490.     frmViewer.ActiveMovie1.ShowSelectionControls = Not frmViewer.ActiveMovie1.ShowSelectionControls
  491.     mnu_View_SelectionControls.Checked = Not mnu_View_SelectionControls.Checked
  492.     ResizeViewer
  493. End Sub
  494. Private Sub mnu_View_Tracker_Click()
  495.     ' Toggles ShowTracker property.
  496.     frmViewer.ActiveMovie1.ShowTracker = Not frmViewer.ActiveMovie1.ShowTracker
  497.     mnu_View_Tracker.Checked = Not mnu_View_Tracker.Checked
  498.     ResizeViewer
  499. End Sub
  500. Private Sub obDoubleOriginal_Click()
  501.   ' Set image size to double original size.
  502.     If g_FileOpened = True Then
  503.         frmViewer.ActiveMovie1.MovieWindowSize = amvDoubleOriginalSize
  504.         Call ResizeViewer
  505.     End If
  506. End Sub
  507. Private Sub obOneFourthScreen_Click()
  508.   ' Set image size to one fourth screen.
  509.     If g_FileOpened = True Then
  510.         frmViewer.ActiveMovie1.MovieWindowSize = amvOneFourthScreen
  511.         Call ResizeViewer
  512.     End If
  513. End Sub
  514. Private Sub obOneHalfScreen_Click()
  515.   ' Set image size to one half screen.
  516.     If g_FileOpened = True Then
  517.         frmViewer.ActiveMovie1.MovieWindowSize = amvOneHalfScreen
  518.         Call ResizeViewer
  519.     End If
  520. End Sub
  521. Private Sub obOneSixteenthScreen_Click()
  522.   ' Set image size to one sixteenth screen.
  523.     If g_FileOpened = True Then
  524.         frmViewer.ActiveMovie1.MovieWindowSize = amvOneSixteenthScreen
  525.         Call ResizeViewer
  526.     End If
  527. End Sub
  528. Private Sub obOriginal_Click()
  529.     ' Set image size to original.
  530.     If g_FileOpened = True Then
  531.         frmViewer.ActiveMovie1.MovieWindowSize = amvOriginalSize
  532.         Call ResizeViewer
  533.     End If
  534. End Sub
  535. Private Sub Slider1_Change()
  536.     ' Set playback rate.
  537.     ' 10 settings, each setting = 0.1
  538.     If g_FileOpened = True Then
  539.         frmViewer.ActiveMovie1.Rate = 0.5 + (0.1 * Slider1.Value)
  540.     End If
  541. End Sub
  542.