home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 4.00 Begin VB.Form frmMain BorderStyle = 3 'Fixed Dialog Caption = "ActiveMovie OCX Sample" ClientHeight = 2916 ClientLeft = 972 ClientTop = 2136 ClientWidth = 5364 Height = 3780 Icon = "ocxvb01.frx":0000 Left = 924 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 2916 ScaleWidth = 5364 ShowInTaskbar = 0 'False Top = 1320 Width = 5460 Begin VB.Frame frmImageSize Caption = "Change Image Size" Enabled = 0 'False Height = 2292 Left = 2880 TabIndex = 9 Top = 120 Width = 2292 Begin VB.OptionButton obNoRestrictions Caption = "No Restrictions" Enabled = 0 'False Height = 255 Left = 240 TabIndex = 16 Top = 1800 Width = 1455 End Begin VB.OptionButton obFixedAspectRatio Caption = "Fixed Aspect Ratio" Enabled = 0 'False Height = 252 Left = 240 TabIndex = 15 Top = 1560 Width = 1692 End Begin VB.OptionButton obFullScreen Caption = "Full Screen" Enabled = 0 'False Height = 255 Left = 240 TabIndex = 14 Top = 1320 Width = 1455 End Begin VB.OptionButton obMaximize Caption = "Maximize" Enabled = 0 'False Height = 255 Left = 240 TabIndex = 13 Top = 1080 Width = 1335 End Begin VB.OptionButton obDouble Caption = "Double" Height = 255 Left = 240 TabIndex = 12 Top = 840 Width = 855 End Begin VB.OptionButton obHalf Caption = "Half" Height = 255 Left = 240 TabIndex = 11 Top = 600 Width = 975 End Begin VB.OptionButton obDefault Caption = "Default" Height = 255 Left = 240 TabIndex = 10 Top = 360 Width = 1095 End End Begin VB.Frame frmPlaybackRate Caption = "Change Playback Rate" Height = 1212 Left = 240 TabIndex = 4 Top = 1200 Width = 2412 Begin VB.Label Label3 Alignment = 2 'Center Caption = "1.5" Height = 252 Left = 1860 TabIndex = 8 Top = 840 Width = 252 End Begin VB.Label Label2 Alignment = 2 'Center Caption = "1.0" Height = 252 Left = 1020 TabIndex = 7 Top = 840 Width = 372 End Begin VB.Label Label1 Alignment = 2 'Center Caption = "0.5" Height = 252 Left = 240 TabIndex = 6 Top = 840 Width = 372 End Begin ComctlLib.Slider Slider1 Height = 492 Left = 240 TabIndex = 5 Top = 240 Width = 1932 _Version = 65536 _ExtentX = 3408 _ExtentY = 868 _StockProps = 64 Enabled = 0 'False LargeChange = 1 TickStyle = 2 End End Begin VB.Frame frmChangeFrames Caption = "Change Current Position" Height = 972 Left = 240 TabIndex = 1 Top = 120 Width = 2412 Begin VB.CommandButton cmdNextFrame Caption = "&>>" Enabled = 0 'False Height = 372 Left = 1320 TabIndex = 3 Top = 360 Width = 852 End Begin VB.CommandButton cmdPreviousFrame Caption = "&<<" Enabled = 0 'False Height = 372 Left = 240 TabIndex = 2 Top = 360 Width = 852 End End Begin ComctlLib.StatusBar StatusBar1 Align = 2 'Align Bottom Height = 408 Left = 0 TabIndex = 0 Top = 2508 Width = 5364 _Version = 65536 _ExtentX = 9462 _ExtentY = 720 _StockProps = 68 AlignSet = -1 'True SimpleText = "" NumPanels = 3 i1 = "ocxvb01.frx":030A i2 = "ocxvb01.frx":0416 i3 = "ocxvb01.frx":0522 End Begin MSComDlg.CommonDialog CommonDialog1 Left = 240 Top = 5880 _Version = 65536 _ExtentX = 677 _ExtentY = 677 _StockProps = 0 End Begin VB.Menu mnu_File Caption = "&File" Begin VB.Menu mnu_File_Open Caption = "&Open" End Begin VB.Menu sep1 Caption = "-" End Begin VB.Menu mnu_File_Run Caption = "&Run" End Begin VB.Menu mnu_File_Pause Caption = "&Pause" End Begin VB.Menu mnu_File_Stop Caption = "&Stop" End Begin VB.Menu sep2 Caption = "-" End Begin VB.Menu mnu_File_Exit Caption = "E&xit" End End Begin VB.Menu mnu_View Caption = "&View" Begin VB.Menu mnu_View_DisplayPanel Caption = "&Display Panel" Checked = -1 'True End Begin VB.Menu sep4 Caption = "-" End Begin VB.Menu mnu_View_ControlPanel Caption = "&Control Panel" Checked = -1 'True End Begin VB.Menu mnu_View_PositionControls Caption = "&Position Controls" Checked = -1 'True End Begin VB.Menu mnu_View_SelectionControls Caption = "&Selection Controls" Checked = -1 'True End Begin VB.Menu mnu_View_Tracker Caption = "&Tracker" Checked = -1 'True End End Begin VB.Menu mnu_Enable Caption = "E&nable" Begin VB.Menu mnu_Enable_PositionControls Caption = "&Position Controls" Checked = -1 'True End Begin VB.Menu mnu_Enable_SelectionControls Caption = "&Selection Controls" Checked = -1 'True End Begin VB.Menu mnu_Enable_Tracker Caption = "&Tracker" Checked = -1 'True End End Begin VB.Menu mnu_Options Caption = "&Options" Begin VB.Menu mnu_Options_AutoRewind Caption = "Auto &Rewind" Checked = -1 'True End Begin VB.Menu mnu_Options_DisplayTime Caption = "Display &Time" Checked = -1 'True End End Begin VB.Menu mnu_events Caption = "&Events" Begin VB.Menu mnu_Events_Keyboard Caption = "&Keyboard" Checked = -1 'True End Begin VB.Menu mnu_Events_MouseClick Caption = "&Mouse Click" Checked = -1 'True End Begin VB.Menu mnu_Events_MouseMove Caption = "Mouse Mo&ve" Checked = -1 'True End Begin VB.Menu mnu_Events_PositionChange Caption = "&Position Change" Checked = -1 'True End Begin VB.Menu mnu_Events_Timer Caption = "&Timer" Checked = -1 'True End Begin VB.Menu mnu_events_state Caption = "&State Change" Checked = -1 'True End End Attribute VB_Name = "frmMain" Attribute VB_Creatable = False Attribute VB_Exposed = False ' ActiveMovie Control Sample ' Copyright (c) 1996 Microsoft Corporation ' All Rights Reserved. Private Sub cmdNextFrame_Click() frmViewer.ActiveMovie1.CurrentPosition = frmViewer.ActiveMovie1.CurrentPosition + 0.1 End Sub Private Sub cmdPreviousFrame_Click() frmViewer.ActiveMovie1.CurrentPosition = frmViewer.ActiveMovie1.CurrentPosition - 0.1 End Sub Private Sub Form_Load() ' ActiveMovie Control Sample Code ' Copyright (c) 1996 Microsoft Corporation ' All Rights Reserved ' This sample demonstrates the ActiveMovie Control. ' It contains the following controls: ' ' The ActiveMovie control (in its own form). ' A status bar control. ' The common dialogs control. ' Two buttons that allow you to step through the stream. ' Option buttons that let you select the stream size. ' A slider that lets you change the playback rate. ' The main form, frmMain, contains several menus that ' control various ActiveMovie controls. ' When events are enabled, a global counter is used to ' keep a running account of each ActiveMovie control event, ' and the value is displayed in the status control. ' Initialize control properties and set menu items to match. Slider1.Value = 5 ' Right in the middle. ' Default value for ActiveMovie1.Rate = 1.0 ' Use default value. obDefault.Value = True With frmViewer.ActiveMovie1 ' Display current position in time, rather than frames. .DisplayMode = modeTime mnu_Options_DisplayTime.Checked = True ' Show the display panel. .ShowDisplay = True mnu_View_DisplayPanel.Checked = True ' Show the control panel and all other controls. .ShowControls = True mnu_View_ControlPanel.Checked = True .ShowPositionControls = False mnu_View_PositionControls.Checked = False .ShowSelectionControls = False mnu_View_SelectionControls.Checked = False .ShowTracker = True mnu_View_Tracker.Checked = True ' Enable the sub-controls on the control panel. .EnablePositionControls = False mnu_Enable_PositionControls.Checked = False .EnableSelectionControls = False mnu_Enable_SelectionControls.Checked = False .EnableTracker = False mnu_Enable_Tracker.Checked = False ' Set AutoRewind. .AutoRewind = True mnu_Options_AutoRewind = True ' Set all event notification flags and check all menu items. .EventNotification = eventError Or eventKeyboard Or eventMouseClick Or eventMouseMove Or eventPositionChange Or eventTimer Or eventStateChange mnu_Events_Keyboard.Checked = True mnu_Events_MouseClick.Checked = True mnu_Events_MouseMove.Checked = True mnu_Events_PositionChange.Checked = True mnu_Events_Timer.Checked = True mnu_events_state.Checked = True End With End Sub Private Sub Form_Unload(Cancel As Integer) End ' end program End Sub Private Sub mnu_Enable_PositionControls_Click() ' Let the user change the prop value from the menu. If (mnu_Enable_PositionControls.Checked) Then mnu_Enable_PositionControls.Checked = False frmViewer.ActiveMovie1.EnablePositionControls = False Else mnu_Enable_PositionControls.Checked = True frmViewer.ActiveMovie1.EnablePositionControls = True End If End Sub Private Sub mnu_Enable_SelectionControls_Click() ' Let the user change the prop value from the menu. If (mnu_Enable_SelectionControls.Checked) Then mnu_Enable_SelectionControls.Checked = False frmViewer.ActiveMovie1.EnableSelectionControls = False Else mnu_Enable_SelectionControls.Checked = True frmViewer.ActiveMovie1.EnableSelectionControls = True End If End Sub Private Sub mnu_Enable_Tracker_Click() ' Let the user change the prop value from the menu. If (mnu_Enable_Tracker.Checked) Then mnu_Enable_Tracker.Checked = False frmViewer.ActiveMovie1.EnableTracker = False Else mnu_Enable_Tracker.Checked = True frmViewer.ActiveMovie1.EnableTracker = True End If End Sub Private Sub mnu_Events_Error_Click() ' Note: These events are not yet implemented in the OCX End Sub Private Sub mnu_Events_Keyboard_Click() With frmViewer.ActiveMovie1 If (mnu_Events_Keyboard.Checked) Then mnu_Events_Keyboard.Checked = False .EventNotification = .EventNotification And (Not eventKeyboard) Else mnu_Events_Keyboard.Checked = True .EventNotification = .EventNotification Or eventKeyboard End If End With End Sub Private Sub mnu_Events_MouseClick_Click() With frmViewer.ActiveMovie1 If (mnu_Events_MouseClick.Checked) Then mnu_Events_MouseClick.Checked = False .EventNotification = .EventNotification And (Not eventMouseClick) Else mnu_Events_MouseClick.Checked = True .EventNotification = .EventNotification Or eventMouseClick End If End With End Sub Private Sub mnu_Events_MouseMove_Click() With frmViewer.ActiveMovie1 If (mnu_Events_MouseMove.Checked) Then mnu_Events_MouseMove.Checked = False .EventNotification = .EventNotification And (Not eventMouseMove) Else mnu_Events_MouseMove.Checked = True .EventNotification = .EventNotification Or eventMouseMove End If End With End Sub Private Sub mnu_Events_PositionChange_Click() With frmViewer.ActiveMovie1 If (mnu_Events_PositionChange.Checked) Then mnu_Events_PositionChange.Checked = False .EventNotification = .EventNotification And (Not eventPositionChange) Else mnu_Events_PositionChange.Checked = True .EventNotification = .EventNotification Or eventPositionChange End If End With End Sub Private Sub mnu_events_state_Click() With frmViewer.ActiveMovie1 If (mnu_Events_Keyboard.Checked) Then mnu_Events_Keyboard.Checked = False .EventNotification = .EventNotification And (Not eventStateChange) Else mnu_Events_Keyboard.Checked = True .EventNotification = .EventNotification Or eventStateChange End If End With End Sub Private Sub mnu_Events_Timer_Click() With frmViewer.ActiveMovie1 If (mnu_Events_Timer.Checked) Then mnu_Events_Timer.Checked = False .EventNotification = .EventNotification And (Not eventTimer) Else mnu_Events_Timer.Checked = True .EventNotification = .EventNotification Or eventTimer End If End With End Sub Private Sub mnu_File_Exit_Click() End ' End program. End Sub Private Sub mnu_File_Open_Click() ' Opens an ActiveMovie file. ' Displays Viewer form if successful. On Error GoTo err_FileOpen 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" CommonDialog1.Flags = 4 'Hide read-only check box CommonDialog1.ShowOpen ' New file resets playback speed to 1.0 Slider1.Value = 5 ' right in the middle ' Default value for ActiveMovie1.Rate = 1.0 ' If did not escape... If CommonDialog1.filename <> "" Then frmViewer.ActiveMovie1.filename = CommonDialog1.filename g_FileOpened = True g_FileExtension = Right$(CommonDialog1.filename, Len(CommonDialog1.filename) - InStr(CommonDialog1.filename, ".")) Else GoTo err_FileOpen End If ' Resize the viewer window to match the image. ResizeViewer ' Reset controls and menu settings for new file. With frmViewer.ActiveMovie1 .ShowPositionControls = False mnu_View_PositionControls.Checked = False .ShowSelectionControls = False mnu_View_SelectionControls.Checked = False .ShowTracker = True mnu_View_Tracker.Checked = True ' Also, enable the sub-controls on the control panel .EnablePositionControls = False mnu_Enable_PositionControls.Checked = False .EnableSelectionControls = False mnu_Enable_SelectionControls.Checked = False .EnableTracker = False mnu_Enable_Tracker.Checked = False ' Enable change position buttons. ' Can't use buttons for .asf files. If g_FileExtension = "asf" Then cmdPreviousFrame.Enabled = False cmdNextFrame.Enabled = False Else cmdPreviousFrame.Enabled = True cmdNextFrame.Enabled = True ' Enable playback rate if avi file. If g_FileExtension = "avi" Then Slider1.Enabled = True End If End If ' Enable frame image size panel. frmImageSize.Enabled = True End With Exit Sub err_FileOpen: MsgBox "File open error.", 0, "ActiveMovie OCX Sample" Exit Sub End Sub Private Sub mnu_File_Pause_Click() ' Pauses the current file. If g_FileOpened = True Then frmViewer.ActiveMovie1.Pause End If End Sub Private Sub mnu_File_Run_Click() ' Starts playing the current file. If g_FileOpened = True Then frmViewer.ActiveMovie1.Run frmViewer.ZOrder 0 End If End Sub Private Sub mnu_File_Stop_Click() ' Stops file play. If g_FileOpened = True Then frmViewer.ActiveMovie1.Stop End If End Sub Private Sub mnu_Options_AutoRewind_Click() ' Toggles the AutoRewind property. If (mnu_Options_AutoRewind.Checked) Then frmViewer.ActiveMovie1.AutoRewind = False mnu_Options_AutoRewind.Checked = False Else frmViewer.ActiveMovie1.AutoRewind = True mnu_Options_AutoRewind.Checked = True End If End Sub Private Sub mnu_Options_DisplayTime_Click() ' Toggles the DisplayMode between time and frames. With frmViewer.ActiveMovie1 If (.DisplayMode = modeTime) Then .DisplayMode = modeFrames mnu_Options_DisplayTime.Checked = False Else .DisplayMode = modeTime mnu_Options_DisplayTime.Checked = True End If End With End Sub Private Sub mnu_View_ControlPanel_Click() ' Toggles the ShowControls property. With frmViewer.ActiveMovie1 If (.AllowHideControls) Then If (.ShowControls) Then .ShowControls = False Else .ShowControls = True End If ' Toggle menu check mark. mnu_View_ControlPanel.Checked = Not mnu_View_ControlPanel.Checked End If End With ResizeViewer End Sub Private Sub mnu_View_DisplayPanel_Click() ' Toggles ShowDisplay property. With frmViewer.ActiveMovie1 If (.AllowHideDisplay) Then If (.ShowDisplay) Then .ShowDisplay = False Else .ShowDisplay = True End If ' Toggle menu check mark. mnu_View_DisplayPanel.Checked = Not mnu_View_DisplayPanel.Checked End If End With ResizeViewer End Sub Private Sub mnu_View_PositionControls_Click() ' Toggles ShowPositionControls property. frmViewer.ActiveMovie1.ShowPositionControls = Not frmViewer.ActiveMovie1.ShowPositionControls mnu_View_PositionControls.Checked = Not mnu_View_PositionControls.Checked ResizeViewer End Sub Private Sub mnu_View_SelectionControls_Click() ' Toggles ShowSelectionControls property. frmViewer.ActiveMovie1.ShowSelectionControls = Not frmViewer.ActiveMovie1.ShowSelectionControls mnu_View_SelectionControls.Checked = Not mnu_View_SelectionControls.Checked ResizeViewer End Sub Private Sub mnu_View_Tracker_Click() ' Toggles ShowTracker property. frmViewer.ActiveMovie1.ShowTracker = Not frmViewer.ActiveMovie1.ShowTracker mnu_View_Tracker.Checked = Not mnu_View_Tracker.Checked ResizeViewer End Sub Private Sub obDefault_Click() ' Set image size to default. If g_FileOpened = True Then frmViewer.ActiveMovie1.MovieWindowSetting = movieDefaultSize Call ResizeViewer End If End Sub Private Sub obDouble_Click() ' Set image size to double. If g_FileOpened = True Then frmViewer.ActiveMovie1.MovieWindowSetting = movieDoubleSize Call ResizeViewer End If End Sub Private Sub obFixedAspectRatio_Click() ' Set MovieWindowSetting to permit resizing while maintaing aspect ratio. If g_FileOpened = True Then frmViewer.ActiveMovie1.MovieWindowSetting = moviePermitResizeWithAspect Call ResizeViewer End If End Sub Private Sub obFullScreen_Click() ' Set image size to full screen. If g_FileOpened = True Then frmViewer.ActiveMovie1.MovieWindowSetting = movieFullScreen Call ResizeViewer End If End Sub Private Sub obHalf_Click() ' Set image size to half. If g_FileOpened = True Then frmViewer.ActiveMovie1.MovieWindowSetting = movieHalfSize Call ResizeViewer End If End Sub Private Sub obMaximize_Click() ' Set image size to maximize. If g_FileOpened = True Then frmViewer.ActiveMovie1.MovieWindowSetting = movieMaximizeSize Call ResizeViewer End If End Sub Private Sub obNoRestrictions_Click() ' Allow image to be sized without restriction. If g_FileOpened = True Then frmViewer.ActiveMovie1.MovieWindowSetting = moviePermitResizeNoRestrict Call ResizeViewer End If End Sub Private Sub Slider1_Change() ' Set playback rate. ' 10 settings, each setting = 0.1 If g_FileOpened = True Then frmViewer.ActiveMovie1.Rate = 0.5 + (0.1 * Slider1.Value) End If End Sub