home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectShow_WinXP / VideoControl / VisualBasic / main.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2001-10-08  |  33.5 KB  |  888 lines

  1. VERSION 5.00
  2. Object = "{B0EDF154-910A-11D2-B632-00C04F79498E}#1.0#0"; "msvidctl.dll"
  3. Begin VB.Form frmMain 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "Microsoft Video Control -  VB Sample Application"
  6.    ClientHeight    =   4875
  7.    ClientLeft      =   2130
  8.    ClientTop       =   2730
  9.    ClientWidth     =   9135
  10.    Icon            =   "main.frx":0000
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   325
  16.    ScaleMode       =   3  'Pixel
  17.    ScaleWidth      =   609
  18.    ShowInTaskbar   =   0   'False
  19.    Begin VB.TextBox txtChannel 
  20.       Height          =   375
  21.       Left            =   1200
  22.       TabIndex        =   25
  23.       Top             =   2160
  24.       Visible         =   0   'False
  25.       Width           =   615
  26.    End
  27.    Begin VB.TextBox txtSID 
  28.       Height          =   375
  29.       Left            =   1200
  30.       TabIndex        =   23
  31.       Top             =   1680
  32.       Visible         =   0   'False
  33.       Width           =   615
  34.    End
  35.    Begin VB.CommandButton cmdInfo 
  36.       Caption         =   "Info"
  37.       Height          =   495
  38.       Left            =   1200
  39.       TabIndex        =   22
  40.       ToolTipText     =   "Display tuner information and FPS count"
  41.       Top             =   1080
  42.       Visible         =   0   'False
  43.       Width           =   855
  44.    End
  45.    Begin VB.CommandButton cmdEnterDVB 
  46.       Caption         =   "Enter"
  47.       Height          =   495
  48.       Left            =   120
  49.       TabIndex        =   20
  50.       ToolTipText     =   "Enter DVB Channel"
  51.       Top             =   1800
  52.       Visible         =   0   'False
  53.       Width           =   975
  54.    End
  55.    Begin VB.CommandButton cmdViewNext 
  56.       Caption         =   "Next Tuner"
  57.       Height          =   495
  58.       Left            =   120
  59.       TabIndex        =   19
  60.       ToolTipText     =   "Select the next tuner in the list"
  61.       Top             =   1080
  62.       Visible         =   0   'False
  63.       Width           =   975
  64.    End
  65.    Begin VB.CommandButton cmdCaptureOff 
  66.       Caption         =   "Hide Capture"
  67.       Height          =   495
  68.       Left            =   7305
  69.       TabIndex        =   18
  70.       ToolTipText     =   "Click to hide the captured frame window"
  71.       Top             =   3960
  72.       Visible         =   0   'False
  73.       Width           =   1695
  74.    End
  75.    Begin VB.CommandButton cmdSeekUpDigital 
  76.       Caption         =   "Ch. Up"
  77.       Height          =   495
  78.       Left            =   1200
  79.       TabIndex        =   17
  80.       ToolTipText     =   "ATSC Physical Channel Up"
  81.       Top             =   3600
  82.       Visible         =   0   'False
  83.       Width           =   975
  84.    End
  85.    Begin VB.CommandButton cmdVolumeDown 
  86.       Caption         =   "Vol. Down"
  87.       Height          =   495
  88.       Left            =   2280
  89.       TabIndex        =   16
  90.       ToolTipText     =   "Click to decrease volume"
  91.       Top             =   4200
  92.       Visible         =   0   'False
  93.       Width           =   975
  94.    End
  95.    Begin VB.CommandButton cmdSeekDownDigital 
  96.       Caption         =   "Ch. Down"
  97.       Height          =   495
  98.       Left            =   1200
  99.       TabIndex        =   15
  100.       ToolTipText     =   "ATSC Physical Channel Down"
  101.       Top             =   4200
  102.       Visible         =   0   'False
  103.       Width           =   975
  104.    End
  105.    Begin VB.CommandButton cmdCapture 
  106.       Caption         =   "Capture Video Frame"
  107.       Height          =   495
  108.       Left            =   4200
  109.       TabIndex        =   14
  110.       ToolTipText     =   "Click to capture a frame of video"
  111.       Top             =   3960
  112.       Visible         =   0   'False
  113.       Width           =   1815
  114.    End
  115.    Begin VB.CommandButton cmdEnterAnalog 
  116.       Caption         =   "Enter"
  117.       Height          =   495
  118.       Left            =   120
  119.       TabIndex        =   13
  120.       ToolTipText     =   "Enter NTSC Channel"
  121.       Top             =   2400
  122.       Visible         =   0   'False
  123.       Width           =   975
  124.    End
  125.    Begin VB.CommandButton cmdEnterATSC 
  126.       Caption         =   "Enter"
  127.       Height          =   495
  128.       Left            =   120
  129.       TabIndex        =   12
  130.       ToolTipText     =   "Enter ATSC Channel"
  131.       Top             =   3000
  132.       Visible         =   0   'False
  133.       Width           =   975
  134.    End
  135.    Begin VB.CommandButton cmdVolumeUp 
  136.       Caption         =   "Vol. Up"
  137.       Height          =   495
  138.       Left            =   2280
  139.       TabIndex        =   11
  140.       ToolTipText     =   "Click to increase volume"
  141.       Top             =   3600
  142.       Visible         =   0   'False
  143.       Width           =   975
  144.    End
  145.    Begin VB.TextBox txtMinorChannel 
  146.       Height          =   375
  147.       Left            =   1200
  148.       TabIndex        =   8
  149.       Top             =   3120
  150.       Visible         =   0   'False
  151.       Width           =   615
  152.    End
  153.    Begin VB.TextBox txtPhysicalChannel 
  154.       Height          =   375
  155.       Left            =   1200
  156.       TabIndex        =   6
  157.       Top             =   2640
  158.       Visible         =   0   'False
  159.       Width           =   615
  160.    End
  161.    Begin VB.CommandButton cmdSeekDownAnalog 
  162.       Caption         =   "Ch. Down"
  163.       Height          =   495
  164.       Left            =   120
  165.       TabIndex        =   5
  166.       ToolTipText     =   "NTSC Channel Down"
  167.       Top             =   4200
  168.       Visible         =   0   'False
  169.       Width           =   975
  170.    End
  171.    Begin VB.CommandButton cmdSeekUpAnalog 
  172.       Caption         =   "Ch. Up"
  173.       Height          =   495
  174.       Left            =   120
  175.       TabIndex        =   4
  176.       ToolTipText     =   "NTSC Channel Up"
  177.       Top             =   3600
  178.       Visible         =   0   'False
  179.       Width           =   975
  180.    End
  181.    Begin VB.CommandButton cmdPowerOff 
  182.       Caption         =   "Power Off"
  183.       Height          =   495
  184.       Left            =   2760
  185.       TabIndex        =   3
  186.       ToolTipText     =   "Done with playback of selected source"
  187.       Top             =   1680
  188.       Visible         =   0   'False
  189.       Width           =   1095
  190.    End
  191.    Begin VB.CommandButton cmdPowerOn 
  192.       Caption         =   "Power On"
  193.       Height          =   495
  194.       Left            =   2760
  195.       TabIndex        =   2
  196.       ToolTipText     =   "Start playing selected source (please be patient)"
  197.       Top             =   1080
  198.       Width           =   1095
  199.    End
  200.    Begin VB.ComboBox cbSource 
  201.       Height          =   315
  202.       Left            =   120
  203.       TabIndex        =   0
  204.       Text            =   "Combo1"
  205.       ToolTipText     =   "Choose one of the tuners from the combo box and press Power On.  Note that building the graph may take up to 10 seconds."
  206.       Top             =   480
  207.       Width           =   3975
  208.    End
  209.    Begin VB.Label lblChannel 
  210.       Caption         =   "Channel"
  211.       Height          =   255
  212.       Left            =   1920
  213.       TabIndex        =   26
  214.       Top             =   2220
  215.       Visible         =   0   'False
  216.       Width           =   735
  217.    End
  218.    Begin VB.Label lblSID 
  219.       Caption         =   "SID"
  220.       Height          =   255
  221.       Left            =   1920
  222.       TabIndex        =   24
  223.       Top             =   1740
  224.       Visible         =   0   'False
  225.       Width           =   495
  226.    End
  227.    Begin VB.Label lblInfo 
  228.       Height          =   375
  229.       Left            =   4200
  230.       TabIndex        =   21
  231.       Top             =   4440
  232.       Visible         =   0   'False
  233.       Width           =   3735
  234.    End
  235.    Begin MSVidCtlLibCtl.MSVidCtl VidControl 
  236.       Height          =   3600
  237.       Left            =   4200
  238.       TabIndex        =   10
  239.       ToolTipText     =   "Microsoft Video Control window"
  240.       Top             =   240
  241.       Width           =   4800
  242.       _cx             =   42672403
  243.       _cy             =   42670286
  244.       AutoSize        =   0   'False
  245.       Enabled         =   -1  'True
  246.       Object.TabStop         =   -1  'True
  247.       BackColor       =   0
  248.    End
  249.    Begin VB.Label lblMinorChannel 
  250.       Caption         =   "Minor Channel"
  251.       Height          =   255
  252.       Left            =   1920
  253.       TabIndex        =   9
  254.       Top             =   3180
  255.       Visible         =   0   'False
  256.       Width           =   1455
  257.    End
  258.    Begin VB.Label lblPhysicalChannel 
  259.       Caption         =   "Physical Channel"
  260.       Height          =   255
  261.       Left            =   1920
  262.       TabIndex        =   7
  263.       Top             =   2700
  264.       Visible         =   0   'False
  265.       Width           =   1335
  266.    End
  267.    Begin VB.Label lblSourceInUse 
  268.       Caption         =   "Playback Source"
  269.       Height          =   255
  270.       Left            =   120
  271.       TabIndex        =   1
  272.       Top             =   120
  273.       Visible         =   0   'False
  274.       Width           =   3975
  275.    End
  276. Attribute VB_Name = "frmMain"
  277. Attribute VB_GlobalNameSpace = False
  278. Attribute VB_Creatable = False
  279. Attribute VB_PredeclaredId = True
  280. Attribute VB_Exposed = False
  281. '*******************************************************************************
  282. '*       This is a part of the Microsoft Platform SDK Code Samples.
  283. '*       Copyright (C) 1999-2001 Microsoft Corporation.
  284. '*       All rights reserved.
  285. '*       This source code is only intended as a supplement to
  286. '*       Microsoft Development Tools and/or SDK documentation.
  287. '*******************************************************************************
  288. 'Microsoft Video Control - Sample Visual Basic Application
  289. Option Explicit
  290. Dim TVPlayer As MSVidAnalogTunerDevice
  291. Dim ATSCTune As IATSCChannelTuneRequest
  292. Dim AnalogTune As IChannelTuneRequest
  293. Dim DVBTune As IDVBTuneRequest
  294. Dim AnalogTV As AnalogTVTuningSpace
  295. Dim ATSCTV As New ATSCTuningSpace
  296. Dim DVBSTV As New DVBSTuningSpace
  297. Dim ATSCLoc As New ATSCLocator
  298. Sub Form_Load()
  299.     cbSource.AddItem ("NTSC Analog TV")
  300.     cbSource.AddItem ("NTSC Analog TV w/CC")
  301.     cbSource.AddItem ("ATSC Digital Antenna TV")
  302.     cbSource.AddItem ("ATSC Digital Antenna TV w/CC & Mixing Mode")
  303.     cbSource.AddItem ("DVB-S Digital TV")
  304.     cbSource.AddItem ("DVB-S Digital TV w/CC & Mixing Mode")
  305.     cbSource.Text = "Choose a playback source and click Power On"
  306. End Sub
  307. Sub cmdPowerOn_click()
  308. 'This function builds the correct graph depending on the user-selected broadcast type
  309.     On Error GoTo ON_ERROR
  310.     Dim TuningSpaceContainer As SystemTuningSpaces
  311.     Set TuningSpaceContainer = CreateObject("BDATuner.SystemTuningSpaces")
  312.     Dim TuningSpaceCollection As ITuningSpaces
  313.     Dim TS As ITuningSpace
  314.     Dim FeaturesColl As New MSVidFeatures
  315.     Dim FeaturesAvailableColl As MSVidFeatures
  316.     Dim Feature As IMSVidFeature
  317.     Dim counter As Integer
  318.     VidControl.MaintainAspectRatio = True
  319.     VidControl.AutoSize = False
  320.     'NTSC Analog TV playback init
  321.     If cbSource.Text = "NTSC Analog TV" Then
  322.         'Find all of the AnalogTV tuning spaces
  323.         Set TuningSpaceCollection = TuningSpaceContainer.TuningSpacesForCLSID(NTSC_GUID)
  324.         If TuningSpaceCollection.Count = 0 Then
  325.             MsgBox ("Couldn't find an NTSC Tuning Space.")
  326.             Call cmdPowerOff_click
  327.             Exit Sub
  328.         End If
  329.         
  330.         'Pick the tuning space named Cable
  331.         For Each TS In TuningSpaceCollection
  332.             If TS.UniqueName = "Cable" Then
  333.                 Set AnalogTV = TS
  334.             End If
  335.         Next
  336.         
  337.         If Not (AnalogTV.UniqueName = "Cable") Then
  338.             MsgBox ("Couldn't find the cable TV tuning space on your system.  Re-install this tuning space.")
  339.             Call cmdPowerOff_click
  340.             Exit Sub
  341.         End If
  342.         
  343.         'Create an AnalogTV tune request and view it
  344.         Set AnalogTune = AnalogTV.CreateTuneRequest
  345.         AnalogTune.Channel = 5
  346.         VidControl.View AnalogTune
  347.         CheckError "There was a problem with passing the analog TV tune request to the MSVidCtl.View() method."
  348.         
  349.         'Set FeaturesActive to nothing to disable CC (if it is on)
  350.         Set FeaturesColl = New MSVidFeatures
  351.         Set FeaturesColl = Nothing
  352.         VidControl.FeaturesActive = FeaturesColl
  353.         CheckError "There was a problem with setting the FeaturesActive collection to NULL."
  354.         
  355.         VidControl.Run
  356.         CheckError "There was a problem running the graph.  Check that your TV tuner card and video card are properly installed."
  357.         If (VidControl.State = STATE_UNBUILT) Then
  358.                 Call cmdPowerOff_click
  359.                 Exit Sub
  360.         End If
  361.         
  362.         txtChannel.Text = VidControl.InputActive.Tune.Channel
  363.         Call MakeAnalogTVToolsVisible
  364.     'NTSC Analog TV playback init w/CC
  365.     ElseIf cbSource.Text = "NTSC Analog TV w/CC" Then
  366.         'Find all of the AnalogTV tuning spaces
  367.         Set TuningSpaceCollection = TuningSpaceContainer.TuningSpacesForCLSID(NTSC_GUID)
  368.         If TuningSpaceCollection.Count = 0 Then
  369.             MsgBox ("Couldn't find an NTSC Tuning Space.")
  370.             Call cmdPowerOff_click
  371.             Exit Sub
  372.         End If
  373.         
  374.         'Pick the tuning space named Cable
  375.         For Each TS In TuningSpaceCollection
  376.             If TS.UniqueName = "Cable" Then
  377.                 Set AnalogTV = TS
  378.             End If
  379.         Next
  380.         
  381.         If Not (AnalogTV.UniqueName = "Cable") Then
  382.             MsgBox ("Couldn't find the cable TV tuning space on your system.  Please reinstall this tuning space.")
  383.             Call cmdPowerOff_click
  384.             Exit Sub
  385.         End If
  386.         
  387.         'Create an AnalogTV tune request and view it
  388.         Set AnalogTune = AnalogTV.CreateTuneRequest
  389.         AnalogTune.Channel = 5
  390.         VidControl.View AnalogTune
  391.         CheckError "There was a problem with passing the analog TV tune request to the MSVidCtl.View() method."
  392.         
  393.         'Enable CC
  394.         Set FeaturesAvailableColl = VidControl.FeaturesAvailable
  395.         CheckError "There was a problem getting the FeaturesAvailable collection."
  396.         
  397.         For Each Feature In FeaturesAvailableColl
  398.             If Feature.ClassID = CC_GUID Then
  399.                 Dim CCObj As MSVidClosedCaptioning
  400.                 Set CCObj = Feature
  401.                 CCObj.Enable = True
  402.                 FeaturesColl.Add Feature
  403.                 CheckError "There was a problem adding a feature to the collection."
  404.             ElseIf Feature.ClassID = DATASVC_GUID Then
  405.                 FeaturesColl.Add Feature
  406.                 CheckError "There was a problem adding a feature to the collection."
  407.             End If
  408.         Next
  409.         VidControl.FeaturesActive = FeaturesColl
  410.         CheckError "There was a problem with setting the FeaturesActive collection."
  411.         
  412.         VidControl.Run
  413.         CheckError "There was a problem running the graph.  Check that your TV tuner card and video card are properly installed."
  414.         If (VidControl.State = STATE_UNBUILT) Then
  415.                 Call cmdPowerOff_click
  416.                 Exit Sub
  417.         End If
  418.         
  419.         txtChannel.Text = VidControl.InputActive.Tune.Channel
  420.         Call MakeAnalogTVToolsVisible
  421.     'Digital TV playback init
  422.     ElseIf cbSource.Text = "ATSC Digital Antenna TV" Then
  423.         'Find the all of ATSC tuning spaces
  424.         Set TuningSpaceCollection = TuningSpaceContainer.TuningSpacesForCLSID(ATSC_GUID)
  425.         If TuningSpaceCollection.Count = 0 Then
  426.             MsgBox ("Couldn't find an ATSC Tuning Space.")
  427.             Call cmdPowerOff_click
  428.             Exit Sub
  429.         End If
  430.         
  431.         'Pick the tuning space named ATSC
  432.         For Each TS In TuningSpaceCollection
  433.             If TS.UniqueName = "ATSC" Then
  434.                 Set ATSCTV = TS
  435.             End If
  436.         Next
  437.         
  438.         If Not (ATSCTV.UniqueName = "ATSC") Then
  439.             MsgBox ("Couldn't find the ATSC TV tuning space on your system.  Please reinstall this tuning space.")
  440.             Call cmdPowerOff_click
  441.             Exit Sub
  442.         End If
  443.         
  444.         'Create a ATSC tune request and view it
  445.         Set ATSCTune = ATSCTV.CreateTuneRequest
  446.         ATSCLoc.PhysicalChannel = 46
  447.         ATSCTune.Channel = -1
  448.         ATSCTune.MinorChannel = -1
  449.         ATSCTune.Locator = ATSCLoc
  450.         
  451.         'Set FeaturesActive to nothing to disable CC (if it is on)
  452.         Set FeaturesColl = New MSVidFeatures
  453.         'Set FeaturesColl = Nothing
  454.         VidControl.FeaturesActive = FeaturesColl
  455.         CheckError "There was a problem with setting the FeaturesActive collection to NULL."
  456.         VidControl.View ATSCTune
  457.         CheckError "There was a problem with passing the ATSC tune request to the MSVidCtl.View() method."
  458.         VidControl.Build
  459.         CheckError "Build"
  460.         VidControl.Run
  461.         CheckError "There was a problem running the graph.  Check that your TV tuner card and video card are properly installed."
  462.         If (VidControl.State = STATE_UNBUILT) Then
  463.             Call cmdPowerOff_click
  464.             Exit Sub
  465.         End If
  466.         
  467.         txtPhysicalChannel.Text = VidControl.InputActive.Tune.Locator.PhysicalChannel
  468.         txtMinorChannel.Text = VidControl.InputActive.Tune.MinorChannel
  469.         Call MakeDigitalTVToolsVisible
  470.         'Hide these two buttons, as we can't mix in this mode
  471.         cmdCapture.Visible = False
  472.         cmdCaptureOff.Visible = False
  473.         
  474.     'Digital TV w/CC playback init
  475.     ElseIf cbSource.Text = "ATSC Digital Antenna TV w/CC & Mixing Mode" Then
  476.         'Find the all of ATSC tuning spaces
  477.         Set TuningSpaceCollection = TuningSpaceContainer.TuningSpacesForCLSID(ATSC_GUID)
  478.         If TuningSpaceCollection.Count = 0 Then
  479.             MsgBox ("Couldn't find an ATSC Tuning Space.")
  480.             Call cmdPowerOff_click
  481.             Exit Sub
  482.         End If
  483.         
  484.         'Pick the tuning space named ATSC
  485.         For Each TS In TuningSpaceCollection
  486.             If TS.UniqueName = "ATSC" Then
  487.                 Set ATSCTV = TS
  488.             End If
  489.         Next
  490.         
  491.         If Not (ATSCTV.UniqueName = "ATSC") Then
  492.             MsgBox ("Couldn't find the ATSC TV tuning space on your system.  Please reinstall this tuning space.")
  493.             Call cmdPowerOff_click
  494.             Exit Sub
  495.         End If
  496.         
  497.         'Create a ATSC tune request and view it
  498.         Set ATSCTune = ATSCTV.CreateTuneRequest
  499.         ATSCLoc.PhysicalChannel = 46
  500.         ATSCTune.Channel = -1
  501.         ATSCTune.MinorChannel = -1
  502.         ATSCTune.Locator = ATSCLoc
  503.         VidControl.View ATSCTune
  504.         CheckError "There was a problem with passing the ATSC tune request to the MSVidCtl.View() method."
  505.         
  506.         'Enable CC (and mixing mode)
  507.         Set FeaturesAvailableColl = VidControl.FeaturesAvailable
  508.         CheckError "There was a problem getting the FeaturesAvailable collection."
  509.         
  510.         For Each Feature In FeaturesAvailableColl
  511.             If Feature.ClassID = CC_GUID Then
  512.                 FeaturesColl.Add Feature
  513.                 CheckError "There was a problem adding a feature to the collection."
  514.             End If
  515.         Next
  516.         VidControl.FeaturesActive = FeaturesColl
  517.         CheckError "There was a problem with putting the FeaturesActive collection."
  518.         
  519.         VidControl.Run
  520.         CheckError "There was a problem running the graph.  Check that your TV tuner card and video card are properly installed."
  521.         If (VidControl.State = STATE_UNBUILT) Then
  522.             Call cmdPowerOff_click
  523.             Exit Sub
  524.         End If
  525.         
  526.         txtPhysicalChannel.Text = VidControl.InputActive.Tune.Locator.PhysicalChannel
  527.         txtMinorChannel.Text = VidControl.InputActive.Tune.MinorChannel
  528.         Call MakeDigitalTVToolsVisible
  529.         
  530.     'Digital DVB-S TV playback init
  531.     ElseIf cbSource.Text = "DVB-S Digital TV" Then
  532.         'Find all of the DVB-S tuning spaces
  533.         Set TuningSpaceCollection = TuningSpaceContainer.TuningSpacesForCLSID(DVBS_GUID)
  534.         If TuningSpaceCollection.Count = 0 Then
  535.             MsgBox ("Couldn't find a DVB Tuning Space.")
  536.             Call cmdPowerOff_click
  537.             Exit Sub
  538.         End If
  539.         
  540.         'Pick any DVB-S tuning space we find
  541.         For Each TS In TuningSpaceCollection
  542.             If TS.UniqueName = "MYDVB" Then
  543.                 Set DVBSTV = TS
  544.                 Exit For
  545.             End If
  546.         Next
  547.         
  548.         If (IsNull(DVBSTV)) Then
  549.             'If there is no tuning space exit
  550.             MsgBox ("No MYDVB tuning space found. Please run the ViewDVB.htm file first")
  551.             Call cmdPowerOff_click
  552.         End If
  553.         'Create a DVB tune request and view it
  554.         Set DVBTune = DVBSTV.CreateTuneRequest
  555.         CheckError "There was a problem creating a DVB-S tune request."
  556.         DVBTune.SID = 101
  557.         
  558.         'Set FeaturesActive to nothing to disable CC (if it is on)
  559.         Set FeaturesColl = New MSVidFeatures
  560.         Set FeaturesColl = Nothing
  561.         VidControl.FeaturesActive = FeaturesColl
  562.         CheckError "There was a problem with setting the FeaturesActive collection to NULL."
  563.         VidControl.View DVBTune
  564.         CheckError "There was a problem with passing the DVB tune request to the MSVidCtl.View() method."
  565.         VidControl.Run
  566.         CheckError "There was a problem running the graph.  Check that your TV tuner card and video card are properly installed."
  567.         If (VidControl.State = STATE_UNBUILT) Then
  568.             Call cmdPowerOff_click
  569.             Exit Sub
  570.         End If
  571.         
  572.         Call MakeDigitalTVToolsVisible
  573.         txtSID.Visible = True
  574.         lblSID.Visible = True
  575.         cmdEnterDVB.Visible = True
  576.         'Hide these buttons, as they aren't used for DVB
  577.         cmdCapture.Visible = False
  578.         cmdCaptureOff.Visible = False
  579.         txtPhysicalChannel.Visible = False
  580.         txtMinorChannel.Visible = False
  581.         lblPhysicalChannel.Visible = False
  582.         lblMinorChannel.Visible = False
  583.         txtChannel.Visible = False
  584.         cmdEnterATSC.Visible = False
  585.         cmdSeekUpDigital.Visible = False
  586.         cmdSeekDownDigital.Visible = False
  587.         
  588.     'Digital DVB-S TV w/CC playback init
  589.     ElseIf cbSource.Text = "DVB-S Digital TV w/CC & Mixing Mode" Then
  590.         'Find all of the DVB-S tuning spaces
  591.         Set TuningSpaceCollection = TuningSpaceContainer.TuningSpacesForCLSID(DVBS_GUID)
  592.         If TuningSpaceCollection.Count = 0 Then
  593.             MsgBox ("Couldn't find a DVB Tuning Space.")
  594.             Call cmdPowerOff_click
  595.             Exit Sub
  596.         End If
  597.         
  598.         'Pick any DVB-S tuning space we find
  599.         For Each TS In TuningSpaceCollection
  600.             If Not (TS Is Nothing) Then
  601.                 Set DVBSTV = TS
  602.             End If
  603.         Next
  604.         
  605.         'Create a DVB tune request and view it
  606.         Set DVBTune = DVBSTV.CreateTuneRequest
  607.         CheckError "There was a problem creating the DVB-S tune request."
  608.         DVBTune.SID = 101
  609.         VidControl.View DVBTune
  610.         CheckError "There was a problem with passing the DVB tune request to the MSVidCtl.View() method."
  611.         
  612.         'Enable CC (and mixing mode)
  613.         Set FeaturesAvailableColl = VidControl.FeaturesAvailable
  614.         CheckError "There was a problem getting the FeaturesAvailable collection."
  615.         
  616.         For Each Feature In FeaturesAvailableColl
  617.             If Feature.ClassID = CC_GUID Then
  618.                 FeaturesColl.Add Feature
  619.                 CheckError "There was a problem adding a feature to the collection."
  620.             End If
  621.         Next
  622.         VidControl.FeaturesActive = FeaturesColl
  623.         CheckError "There was a problem with putting the FeaturesActive collection."
  624.         
  625.         VidControl.Run
  626.         CheckError "There was a problem running the graph.  Check that your TV tuner card and video card are properly installed."
  627.         If (VidControl.State = STATE_UNBUILT) Then
  628.             Call cmdPowerOff_click
  629.             Exit Sub
  630.         End If
  631.         
  632.         Call MakeDigitalTVToolsVisible
  633.         txtSID.Visible = True
  634.         lblSID.Visible = True
  635.         cmdEnterDVB.Visible = True
  636.         'Hide the objects that aren't needed for DVB
  637.         txtPhysicalChannel.Visible = False
  638.         txtMinorChannel.Visible = False
  639.         lblPhysicalChannel.Visible = False
  640.         lblMinorChannel.Visible = False
  641.         txtChannel.Visible = False
  642.         cmdEnterATSC.Visible = False
  643.         cmdSeekUpDigital.Visible = False
  644.         cmdSeekDownDigital.Visible = False
  645.         
  646.     'User didn't pick a playback type
  647.     Else
  648.         MsgBox "You have chosen a playback type that is not implemented.  Please try again."
  649.     End If
  650.     Exit Sub
  651. ON_ERROR:
  652.     Call ProcessGeneralErorr
  653. End Sub
  654. Sub ProcessGeneralErorr()
  655.     On Error Resume Next
  656.     VidControl.Stop
  657.     VidControl.Decompose
  658.     ATSCTune = Null
  659.     AnalogTune = Null
  660.     DVBTune = Null
  661.     AnalogTV = Null
  662.     ATSCTV = Null
  663.     DVBSTV = Null
  664.     ATSCLoc = Null
  665.     CheckError "General error - graph cannot run"
  666. End Sub
  667. 'User is done with this playback
  668. Sub cmdPowerOff_click()
  669.     On Error Resume Next
  670.     Call HideTools
  671.     VidControl.Stop
  672.     VidControl.Decompose
  673.     CheckError "There was a problem tearing down the graph."
  674. End Sub
  675. Sub MakeAnalogTVToolsVisible()
  676. 'Make the appropriate analog TV controls visible
  677.     cmdPowerOff.Visible = True
  678.     cmdCapture.Visible = True
  679.     cmdCaptureOff.Visible = True
  680.     cmdEnterAnalog.Visible = True
  681.     lblChannel.Visible = True
  682.     txtChannel.Visible = True
  683.     lblSourceInUse.Caption = cbSource.Text
  684.     lblSourceInUse.Visible = True
  685.     cbSource.Visible = False
  686.     txtChannel.Text = AnalogTune.Channel
  687.     cmdVolumeUp.Visible = True
  688.     cmdVolumeDown.Visible = True
  689.     cmdSeekUpAnalog.Visible = True
  690.     cmdSeekDownAnalog.Visible = True
  691.     cmdViewNext.Visible = True
  692.     cmdInfo.Visible = True
  693. End Sub
  694. Sub MakeDigitalTVToolsVisible()
  695. 'Make the appropriate TV controls visible
  696.     cmdPowerOff.Visible = True
  697.     cmdCapture.Visible = True
  698.     cmdCaptureOff.Visible = True
  699.     cmdSeekUpDigital.Visible = True
  700.     cmdSeekDownDigital.Visible = True
  701.     cmdEnterATSC.Visible = True
  702.     lblSourceInUse.Caption = cbSource.Text
  703.     cbSource.Visible = False
  704.     lblSourceInUse.Visible = True
  705.     lblMinorChannel.Visible = True
  706.     txtMinorChannel.Visible = True
  707.     lblPhysicalChannel.Visible = True
  708.     txtPhysicalChannel.Visible = True
  709.     cmdVolumeUp.Visible = True
  710.     cmdVolumeDown.Visible = True
  711.     cmdViewNext.Visible = True
  712.     cmdInfo.Visible = True
  713. End Sub
  714. 'Hide all the controls we don't need to see
  715. Sub HideTools()
  716.     cmdPowerOff.Visible = False
  717.     cmdCapture.Visible = False
  718.     cmdCaptureOff.Visible = False
  719.     cmdSeekUpAnalog.Visible = False
  720.     cmdSeekDownAnalog.Visible = False
  721.     cmdSeekUpDigital.Visible = False
  722.     cmdSeekDownDigital.Visible = False
  723.     cmdEnterATSC.Visible = False
  724.     cmdEnterAnalog.Visible = False
  725.     lblChannel.Visible = False
  726.     txtChannel.Visible = False
  727.     cbSource.Visible = True
  728.     lblSourceInUse.Visible = False
  729.     lblMinorChannel.Visible = False
  730.     txtMinorChannel.Visible = False
  731.     lblPhysicalChannel.Visible = False
  732.     txtPhysicalChannel.Visible = False
  733.     cmdVolumeUp.Visible = False
  734.     cmdVolumeDown.Visible = False
  735.     cmdViewNext.Visible = False
  736.     txtSID.Visible = False
  737.     cmdEnterDVB.Visible = False
  738.     lblSID.Visible = False
  739.     lblInfo.Visible = False
  740.     cmdInfo.Visible = False
  741. End Sub
  742. 'User presses Enter button to change a DVB-S channel
  743. Private Sub cmdEnterDVB_Click()
  744.     On Error Resume Next
  745.     DVBTune.SID = txtSID.Text
  746.     VidControl.View DVBTune
  747.     CheckError "There was a problem with passing the DVB tune request to the MSVidCtl.View() method."
  748. End Sub
  749. 'User presses Enter button to change a ATSC channel
  750. Private Sub cmdEnterATSC_Click()
  751.     On Error Resume Next
  752.     ATSCLoc.PhysicalChannel = txtPhysicalChannel.Text
  753.     ATSCTune.Locator = ATSCLoc
  754.     ATSCTune.MinorChannel = txtMinorChannel.Text
  755.     ATSCTune.Channel = -1
  756.     VidControl.View ATSCTune
  757.     CheckError "There was a problem with passing the ATSC tune request to the MSVidCtl.View() method."
  758.     txtPhysicalChannel.Text = VidControl.InputActive.Tune.Locator.PhysicalChannel
  759.     txtMinorChannel.Text = VidControl.InputActive.Tune.MinorChannel
  760. End Sub
  761. 'User presses Enter button to change a NTSC channel
  762. Private Sub cmdEnterAnalog_Click()
  763.     On Error Resume Next
  764.     AnalogTune.Channel = txtChannel.Text
  765.     VidControl.View AnalogTune
  766.     CheckError "There was a problem with passing the analog TV tune request to the MSVidCtl.View() method."
  767.     txtChannel.Text = VidControl.InputActive.Tune.Channel
  768. End Sub
  769. 'Change volume
  770. Private Sub cmdVolumeUp_Click()
  771.     On Error Resume Next
  772.     If (VidControl.AudioRendererActive.Volume < 0) Then
  773.         VidControl.AudioRendererActive.Volume = VidControl.AudioRendererActive.Volume + 1000
  774.         CheckError "There was a problem with changing the volume."
  775.     'Else
  776.     '    MsgBox "Volume is set to maximum."
  777.     End If
  778. End Sub
  779. 'Change volume
  780. Private Sub cmdVolumeDown_Click()
  781.     On Error Resume Next
  782.     If (VidControl.AudioRendererActive.Volume > -10000) Then
  783.         VidControl.AudioRendererActive.Volume = VidControl.AudioRendererActive.Volume - 1000
  784.         CheckError "There was a problem with changing the volume."
  785.     'Else
  786.     '    MsgBox "Volume is set to minimum."
  787.     End If
  788. End Sub
  789. 'Channel change up for ATSC
  790. Private Sub cmdSeekUpDigital_Click()
  791.     On Error Resume Next
  792.     ATSCLoc.PhysicalChannel = ATSCLoc.PhysicalChannel + 1
  793.     ATSCTune.Locator = ATSCLoc
  794.     ATSCTune.MinorChannel = -1
  795.     ATSCTune.Channel = -1
  796.     VidControl.View ATSCTune
  797.     CheckError "There was a problem with passing the ATSC tune request to the MSVidCtl.View() method."
  798.     txtPhysicalChannel.Text = VidControl.InputActive.Tune.Locator.PhysicalChannel
  799.     txtMinorChannel.Text = VidControl.InputActive.Tune.MinorChannel
  800. End Sub
  801. 'Channel change down for ATSC
  802. Private Sub cmdSeekDownDigital_Click()
  803.     On Error Resume Next
  804.     ATSCLoc.PhysicalChannel = ATSCLoc.PhysicalChannel - 1
  805.     ATSCTune.Locator = ATSCLoc
  806.     ATSCTune.MinorChannel = -1
  807.     ATSCTune.Channel = -1
  808.     VidControl.View ATSCTune
  809.     CheckError "There was a problem with passing the ATSC tune request to the MSVidCtl.View() method."
  810.     txtPhysicalChannel.Text = VidControl.InputActive.Tune.Locator.PhysicalChannel
  811.     txtMinorChannel.Text = VidControl.InputActive.Tune.MinorChannel
  812. End Sub
  813. 'Channel change up for NTSC
  814. Private Sub cmdSeekUpAnalog_Click()
  815.     On Error Resume Next
  816.     AnalogTune.Channel = AnalogTune.Channel + 1
  817.     VidControl.View AnalogTune
  818.     CheckError "There was a problem with passing the ATSC tune request to the MSVidCtl.View() method."
  819.     txtChannel.Text = VidControl.InputActive.Tune.Channel
  820. End Sub
  821. 'Channel change down for NTSC
  822. Private Sub cmdSeekDownAnalog_Click()
  823.     On Error Resume Next
  824.     AnalogTune.Channel = AnalogTune.Channel - 1
  825.     VidControl.View AnalogTune
  826.     CheckError "There was a problem with passing the ATSC tune request to the MSVidCtl.View() method."
  827.     txtChannel.Text = VidControl.InputActive.Tune.Channel
  828. End Sub
  829. 'Capture current video frame and alpha blend over video
  830. Private Sub cmdCapture_Click()
  831.     On Error Resume Next
  832.     Dim Alpha As Integer
  833.     Dim TempVidRend As MSVidVideoRenderer
  834.     Dim MyRect As IMSVidRect
  835.     Dim Pict As IPictureDisp
  836.     'The amount of opacity for the image over video is 75% visible
  837.     Alpha = 75
  838.     'Get the current video renderer
  839.     Set TempVidRend = VidControl.VideoRendererActive
  840.     CheckError "Failed to retrieve the current video renderer."
  841.     'Capture the frame of video
  842.     Set Pict = TempVidRend.Capture
  843.     CheckError "Failed to capture the video frame."
  844.     'Set the properties for the image and then display it
  845.     TempVidRend.MixerBitmap = Pict
  846.     TempVidRend.MixerBitmapOpacity = Alpha
  847.     Set MyRect = TempVidRend.MixerBitmapPositionRect
  848.     MyRect.Top = 10
  849.     MyRect.Left = 10
  850.     MyRect.Height = (VidControl.Height) / 4
  851.     MyRect.Width = (VidControl.Width) / 4
  852.     TempVidRend.MixerBitmapPositionRect = MyRect
  853.     CheckError "Failed to display the frame capture.  Your video card may not be compatible with the WindowsXP Video Mixing Renderer."
  854. End Sub
  855. 'Remove the alpha blended image
  856. Private Sub cmdCaptureOff_Click()
  857.     On Error Resume Next
  858.     Dim TempVidRend As MSVidVideoRenderer
  859.     Set TempVidRend = VidControl.VideoRendererActive
  860.     CheckError "Failed to retrieve the current video renderer."
  861.     TempVidRend.MixerBitmap = Nothing
  862.     CheckError "Failed to disable MixerBitmap."
  863. End Sub
  864. Private Sub cmdViewNext_Click()
  865. 'Try the next tuner device
  866.     On Error Resume Next
  867.     VidControl.Stop
  868.     If VidControl.InputActive.TuningSpace.CLSID = NTSC_GUID Then
  869.         VidControl.ViewNext AnalogTune
  870.         CheckError "Failed to ViewNext for NTSC."
  871.     ElseIf VidControl.InputActive.TuningSpace.CLSID = ATSC_GUID Then
  872.         VidControl.ViewNext ATSCTune
  873.         CheckError "Failed to ViewNext for ATSC."
  874.     ElseIf VidControl.InputActive.TuningSpace.CLSID = DVBS_GUID Then
  875.         VidControl.ViewNext DVBTune
  876.         CheckError "Failed to ViewNext for DVB."
  877.     Else
  878.         MsgBox "There is not a tuning space to match the current InputActive."
  879.     End If
  880.     VidControl.Run
  881.     CheckError "Unable to run after changing InputActive."
  882. End Sub
  883. Private Sub cmdInfo_Click()
  884. 'Display Input Name and FPS
  885.     lblInfo.Visible = True
  886.     lblInfo.Caption = "Device Name: " & VidControl.InputActive.Name & "  FPS: " & (VidControl.VideoRendererActive.FramesPerSecond / 100)
  887. End Sub
  888.