home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / ActiveX Controlls / CD Writer Pro ActiveX Control / CD Writer Pro ActiveX Control.exe / %MAINDIR% / VBSample2 / frmMain.frm (.txt) next >
Encoding:
Visual Basic Form  |  2003-04-16  |  25.8 KB  |  675 lines

  1. VERSION 5.00
  2. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  3. Object = "{B826C06B-C37C-4A6C-BEB8-53B5CEF374C9}#1.0#0"; "CDRProX.tlb"
  4. Begin VB.Form frmMain 
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "CDWriterPro Sample2"
  7.    ClientHeight    =   5655
  8.    ClientLeft      =   150
  9.    ClientTop       =   435
  10.    ClientWidth     =   6015
  11.    Icon            =   "frmMain.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   5655
  15.    ScaleWidth      =   6015
  16.    StartUpPosition =   1  'CenterOwner
  17.    Begin VB.Frame fraOptions 
  18.       Caption         =   "Write Options"
  19.       Height          =   1470
  20.       Left            =   3375
  21.       TabIndex        =   13
  22.       Top             =   3825
  23.       Width           =   2520
  24.       Begin VB.CheckBox chkCacheFiles 
  25.          Caption         =   "Cach files locally"
  26.          Height          =   240
  27.          Left            =   165
  28.          TabIndex        =   16
  29.          Top             =   405
  30.          Value           =   1  'Checked
  31.          Width           =   2295
  32.       End
  33.       Begin VB.CheckBox chkTestWrite 
  34.          Caption         =   "Test Mode "
  35.          Height          =   240
  36.          Left            =   165
  37.          TabIndex        =   15
  38.          Top             =   712
  39.          Width           =   2025
  40.       End
  41.       Begin VB.CheckBox chkUseBurnProof 
  42.          Caption         =   "Use Buffer Protection"
  43.          Height          =   240
  44.          Left            =   165
  45.          TabIndex        =   14
  46.          Top             =   1020
  47.          Width           =   2025
  48.       End
  49.    End
  50.    Begin VB.CommandButton cmdCancel 
  51.       Caption         =   "&Cancel"
  52.       Height          =   375
  53.       Left            =   105
  54.       TabIndex        =   12
  55.       Top             =   4920
  56.       Width           =   1575
  57.    End
  58.    Begin VB.CommandButton cmdWriteDisc 
  59.       Caption         =   "&Write Disc"
  60.       Height          =   375
  61.       Left            =   1680
  62.       TabIndex        =   11
  63.       Top             =   4920
  64.       Width           =   1575
  65.    End
  66.    Begin MSComctlLib.StatusBar sbrStatus 
  67.       Align           =   2  'Align Bottom
  68.       Height          =   300
  69.       Left            =   0
  70.       TabIndex        =   10
  71.       Top             =   5355
  72.       Width           =   6015
  73.       _ExtentX        =   10610
  74.       _ExtentY        =   529
  75.       Style           =   1
  76.       SimpleText      =   "Add Audio Files"
  77.       _Version        =   393216
  78.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  79.          NumPanels       =   1
  80.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  81.          EndProperty
  82.       EndProperty
  83.    End
  84.    Begin VB.ComboBox cboDevices 
  85.       Height          =   315
  86.       Left            =   585
  87.       Style           =   2  'Dropdown List
  88.       TabIndex        =   4
  89.       Top             =   75
  90.       Width           =   2835
  91.    End
  92.    Begin VB.ComboBox cboWriteSpeed 
  93.       Height          =   315
  94.       Left            =   4845
  95.       Style           =   2  'Dropdown List
  96.       TabIndex        =   2
  97.       Top             =   75
  98.       Width           =   1095
  99.    End
  100.    Begin MSComctlLib.ListView lvwAudioTracks 
  101.       Height          =   2820
  102.       Left            =   60
  103.       TabIndex        =   0
  104.       Top             =   780
  105.       Width           =   5895
  106.       _ExtentX        =   10398
  107.       _ExtentY        =   4974
  108.       View            =   3
  109.       LabelEdit       =   1
  110.       LabelWrap       =   -1  'True
  111.       HideSelection   =   0   'False
  112.       OLEDragMode     =   1
  113.       OLEDropMode     =   1
  114.       FullRowSelect   =   -1  'True
  115.       _Version        =   393217
  116.       ForeColor       =   -2147483640
  117.       BackColor       =   -2147483643
  118.       BorderStyle     =   1
  119.       Appearance      =   1
  120.       OLEDragMode     =   1
  121.       OLEDropMode     =   1
  122.       NumItems        =   4
  123.       BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  124.          Text            =   "Track"
  125.          Object.Width           =   1764
  126.       EndProperty
  127.       BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  128.          SubItemIndex    =   1
  129.          Text            =   "File Name"
  130.          Object.Width           =   4939
  131.       EndProperty
  132.       BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  133.          Alignment       =   2
  134.          SubItemIndex    =   2
  135.          Text            =   "Type"
  136.          Object.Width           =   1764
  137.       EndProperty
  138.       BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
  139.          Alignment       =   2
  140.          SubItemIndex    =   3
  141.          Text            =   "Time"
  142.          Object.Width           =   1940
  143.       EndProperty
  144.    End
  145.    Begin MSComctlLib.ProgressBar prgTrackProgress 
  146.       Height          =   300
  147.       Left            =   75
  148.       TabIndex        =   6
  149.       Top             =   3945
  150.       Width           =   3225
  151.       _ExtentX        =   5689
  152.       _ExtentY        =   529
  153.       _Version        =   393216
  154.       Appearance      =   1
  155.       Scrolling       =   1
  156.    End
  157.    Begin MSComctlLib.ProgressBar prgTotalProgress 
  158.       Height          =   300
  159.       Left            =   75
  160.       TabIndex        =   7
  161.       Top             =   4545
  162.       Width           =   3225
  163.       _ExtentX        =   5689
  164.       _ExtentY        =   529
  165.       _Version        =   393216
  166.       Appearance      =   1
  167.       Scrolling       =   1
  168.    End
  169.    Begin CDRPROXLibCtl.CDWriterPro CDWriterPro1 
  170.       Left            =   3390
  171.       OleObjectBlob   =   "frmMain.frx":0442
  172.       Top             =   -30
  173.    End
  174.    Begin VB.Label lblTrackWritten 
  175.       Caption         =   "Track Written"
  176.       Height          =   285
  177.       Left            =   75
  178.       TabIndex        =   9
  179.       Top             =   3675
  180.       Width           =   1005
  181.    End
  182.    Begin VB.Label lblTotalWritten 
  183.       Caption         =   "Total Written"
  184.       Height          =   285
  185.       Left            =   75
  186.       TabIndex        =   8
  187.       Top             =   4305
  188.       Width           =   1065
  189.    End
  190.    Begin VB.Label lblRecorder 
  191.       Alignment       =   1  'Right Justify
  192.       Caption         =   "Drive:"
  193.       Height          =   225
  194.       Left            =   -165
  195.       TabIndex        =   5
  196.       Top             =   120
  197.       Width           =   720
  198.    End
  199.    Begin VB.Label lblWriteSpeed 
  200.       Alignment       =   1  'Right Justify
  201.       Caption         =   "Write Speed"
  202.       Height          =   255
  203.       Left            =   3780
  204.       TabIndex        =   3
  205.       Top             =   120
  206.       Width           =   975
  207.    End
  208.    Begin VB.Label lblImageFileTitle 
  209.       BorderStyle     =   1  'Fixed Single
  210.       Caption         =   "Audio Tracks - Drag and Drop .wav Files"
  211.       Height          =   270
  212.       Left            =   105
  213.       TabIndex        =   1
  214.       Top             =   495
  215.       Width           =   5835
  216.    End
  217.    Begin VB.Menu mnuFile 
  218.       Caption         =   "&File"
  219.       Begin VB.Menu mnuFileClear 
  220.          Caption         =   "Clear All Items"
  221.          Shortcut        =   ^C
  222.       End
  223.       Begin VB.Menu mnuFileRemove 
  224.          Caption         =   "Remove Track"
  225.       End
  226.       Begin VB.Menu mnuFileSep2 
  227.          Caption         =   "-"
  228.       End
  229.       Begin VB.Menu mnuFileExit 
  230.          Caption         =   "Exit"
  231.          Shortcut        =   ^X
  232.       End
  233.    End
  234.    Begin VB.Menu mnuCDRecorder 
  235.       Caption         =   "&CD-Recorder"
  236.       Begin VB.Menu mnuCDRecorderEject 
  237.          Caption         =   "Eject"
  238.          Shortcut        =   ^J
  239.       End
  240.       Begin VB.Menu mnuCDRecorderCloseTray 
  241.          Caption         =   "Close Tray"
  242.          Shortcut        =   ^T
  243.       End
  244.    End
  245.    Begin VB.Menu mnuHelp 
  246.       Caption         =   "&Help"
  247.       Begin VB.Menu mnuHelpAbout 
  248.          Caption         =   "About"
  249.       End
  250.    End
  251. Attribute VB_Name = "frmMain"
  252. Attribute VB_GlobalNameSpace = False
  253. Attribute VB_Creatable = False
  254. Attribute VB_PredeclaredId = True
  255. Attribute VB_Exposed = False
  256. Option Explicit
  257. Private mlngCurrentDrive As Long
  258. Private mintTracksToWrite As Integer
  259. Private mblnUnloadOk As Boolean
  260. Private mintCurrentTrackCaching As Integer
  261. '****************************************************************
  262. '****************************************************************
  263. 'COPYRIGHT 2003 NUMEDIA SOFT, INC
  264. 'This is a sample of how you could use the CDWriterPro control to
  265. 'record audio CDs from .wav files. There are improvements which could
  266. 'be made rather easily. Feel free to modify it as you see fit.
  267. '****************************************************************
  268. '****************************************************************
  269. Private Sub CDWriterPro1_CachingStatus(ByVal nPercentComplete As Integer)
  270.     sbrStatus.SimpleText = "Caching" & " - %" & Format(nPercentComplete, "0#")
  271. End Sub
  272. Private Sub CDWriterPro1_ClosingDisc()
  273.     sbrStatus.SimpleText = "Closing Disc...."
  274. End Sub
  275. Private Sub CDWriterPro1_ClosingTrack(ByVal lTrackNumber As Long)
  276.     sbrStatus.SimpleText = "Closing Track....#" & Format(lTrackNumber, "0#")
  277. End Sub
  278. Private Sub CDWriterPro1_EnumAudioTrack(ByVal sFileName As String, ByVal lTotalSizeBlocks As Long, ByVal lTotalSizeBytes As Long, ByVal lTrackNumber As Long)
  279.     Dim lstItem As ListItem
  280.     'Add to the list view
  281.     Set lstItem = lvwAudioTracks.ListItems.Add(, , Format(lTrackNumber, "0#"))
  282.     lstItem.SubItems(1) = sFileName
  283.     lstItem.SubItems(2) = "WAV"
  284.     lstItem.SubItems(3) = CDWriterPro1.ConvertBlocksToMSFString(lTotalSizeBlocks)
  285. End Sub
  286. Private Sub CDWriterPro1_PreparingToWrite()
  287.     sbrStatus.SimpleText = "Preparing to Write Disc...."
  288.     prgTotalProgress.Value = 0
  289.     prgTrackProgress.Value = 0
  290.     'Disable buttons as we start to write
  291.     Call EnableForm(False)
  292. End Sub
  293. Private Sub CDWriterPro1_ReadingTrackFile(ByVal sFileName As String, ByVal lFileIndex As Long, ByVal lTrackNumber As Long)
  294.     mintCurrentTrackCaching = lTrackNumber
  295.     sbrStatus.Panels(1).Text = "Track: " & Format(lTrackNumber, "0#") & " - Reading..." & CStr(lFileIndex) & " - " & sFileName
  296. End Sub
  297. Private Sub CDWriterPro1_TrackWriteStatus(ByVal lTrackNumber As Long, ByVal lBlocksWritten As Long, ByVal lBlocksToWrite As Long)
  298.     Dim intPercentTrackWritten As Integer
  299.     Dim intPercentTotalTracksWritten As Integer
  300.     On Error Resume Next
  301.     'Calc Percent of Current track done
  302.     intPercentTrackWritten = ((lBlocksWritten / lBlocksToWrite) * 100)
  303.     'Audio Files
  304.     'Calc the percentage of the current track into the Total
  305.     intPercentTotalTracksWritten = (((lTrackNumber - 1 + (intPercentTrackWritten / 100)) / mintTracksToWrite) * 100)
  306.     'Set Progress Bars
  307.     prgTrackProgress.Value = intPercentTrackWritten
  308.     prgTotalProgress.Value = intPercentTotalTracksWritten
  309.     sbrStatus.SimpleText = "Writing Track #" & Format(lTrackNumber, "0#") & "... "
  310. End Sub
  311. Private Sub CDWriterPro1_WriteCancelled()
  312.     sbrStatus.SimpleText = "Writing Cancelled......"
  313.     Call EnableForm(True)
  314. End Sub
  315. Private Sub CDWriterPro1_WriteComplete()
  316.     sbrStatus.SimpleText = "Writing Complete!"
  317.     'Enable the form
  318.     Call EnableForm(True)
  319.     'Completed Message
  320.     MsgBox "Writing is complete!", vbInformation + vbOKOnly, App.Title
  321.     'Eject if not in test mode
  322.     If CDWriterPro1.TestWrite = False Then
  323.         'Eject disc
  324.     Call CDWriterPro1.EjectLoad(False)
  325.     End If
  326. End Sub
  327. Private Sub cmdCancel_Click()
  328.     'Cancel recording
  329.     sbrStatus.SimpleText = "Aborting Write...Please Wait!"
  330.     Call CDWriterPro1.CancelWrite
  331. End Sub
  332. Private Sub cmdWriteDisc_Click()
  333.     'Check for a valid Drive
  334.     If mlngCurrentDrive = -1 Then
  335.         MsgBox "A drive is not selected or does not exist.", vbInformation + vbOKOnly, App.Title
  336.         Exit Sub
  337.     End If
  338.     'Check to make sure we have a disc
  339.     If CDWriterPro1.GetMediaType() = mtNotLoaded Then
  340.         MsgBox "Please load an empty disc for recording.", vbInformation + vbOKOnly, App.Title
  341.         Exit Sub
  342.     End If
  343.     'Check to make sure we have a CD or CDRW only loaded...no DVD media types
  344.     If Not ((CDWriterPro1.GetMediaType() = mtCD) Or (CDWriterPro1.GetMediaType() = mtCDRW)) Then
  345.         MsgBox "Please load an empty CD or CDR/W Only...DVDs do not allow audio recording.", vbInformation + vbOKOnly, App.Title
  346.         Exit Sub
  347.     End If
  348.     'Check to make sure we have an empty disc
  349.     If CDWriterPro1.GetDiscStatus() <> dsEmpty Then
  350.         MsgBox "Please insert an empty disc for recording.", vbInformation + vbOKOnly, App.Title
  351.         Exit Sub
  352.     End If
  353.     'Set the caching property
  354.     'This set to true will cache audio files prior to writing each track
  355.     'It is highly recommended to use this setting for slower CPU's or machines
  356.     'with low amount of memory (under 128 MB)...otherwise a buffer underrun may occur.
  357.     'Also use this setting to write from files in a network location...
  358.     CDWriterPro1.CacheImage = (chkCacheFiles.Value = vbChecked)
  359.     'Audio Disc type
  360.     CDWriterPro1.WriteType = wtpCDDA
  361.     'Test write mode
  362.     CDWriterPro1.TestWrite = (chkTestWrite.Value = vbChecked)
  363.     CDWriterPro1.CloseDisc = True 'Audio discs should be closed
  364.     CDWriterPro1.CloseSession = True 'Audio discs should have closed sessions
  365.     'Start the disc writing process..this should alway return True
  366.     'If there is an error, the Error event will fire...
  367.     'If this returns false, there is a system problem
  368.     'Use Burn Proof if possible to prevent buffer under-runs...
  369.     'the drive must support this feature
  370.     Call CDWriterPro1.SetBufferProtection(chkUseBurnProof.Value = vbChecked)
  371.     If CDWriterPro1.WriteDisc() = False Then
  372.         MsgBox "Disc Write could not be started.", vbCritical, App.Title
  373.     End If
  374. End Sub
  375. Private Sub CDWriterPro1_WriteError(ByVal WriteError As CDRPROXLibCtl.eWriteErrorType, ByVal DriveError As CDRPROXLibCtl.eCDError, ByVal sErrorInfo As String, ByVal sSenseInfo As String)
  376.     Dim strError As String
  377.     'Get the error type and
  378.     strError = "Writing Error: (" & CStr(WriteError) & ")   " & sErrorInfo & vbCrLf
  379.     'If it is a drive error, add the drive error information
  380.     'to the displayed message
  381.     If WriteError = errDriveError Then
  382.         strError = strError & GetDriveErrorMessage(DriveError) & vbCrLf & " Error Sense Data: " & sSenseInfo
  383.     End If
  384.     'Display Msg to user
  385.     MsgBox strError, vbCritical + vbOKOnly
  386.     Call EnableForm(True)
  387. End Sub
  388. Private Sub Form_Load()
  389.     'Display Version
  390.     Me.Caption = "Sample2 CDWriterPro - Version " & CDWriterPro1.GetVersion()
  391.         
  392.     'VERY IMPORTANT - Initialize the drives
  393.     'The control will not function properly without calling this function first
  394.     'Optiontally you can use ASPI for NT, but not recommended
  395.     If CDWriterPro1.InitDrives(False) = False Then
  396.         MsgBox "Drives Cannot be initialized...Contact support!"
  397.     End If
  398.         
  399. '*************** ENABLE LOGGING CODE
  400. '    'Enable logging?
  401. '    If CDWriterPro1.SetLogging("C:\DVDTestlog.txt", True) = False Then
  402. '        MsgBox "Error enabling logging!"
  403. '    End If
  404. '*************** END LOGGING CODE
  405.     'Load the Drives
  406.     LoadDriveCombo
  407.     'Make sure the form is enabled
  408.     Call EnableForm(True)
  409. End Sub
  410. Private Sub Form_Unload(Cancel As Integer)
  411.     'Don't Unload if we are writing
  412.     Cancel = Not mblnUnloadOk
  413. End Sub
  414. Private Sub lvwAudioTracks_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
  415.     Dim strTempPath As String
  416.     Dim varItem As Variant
  417.     Dim intSelTrack As Integer
  418.     'Dont worry about error handling to much for this demo
  419.     On Error Resume Next
  420.     'Lets insert a track if we have one selcted
  421.     If Not (lvwAudioTracks.SelectedItem Is Nothing) Then
  422.         intSelTrack = lvwAudioTracks.SelectedItem.Index
  423.     Else
  424.         intSelTrack = 1
  425.     End If
  426.             
  427.     If Data.GetFormat(vbCFFiles) = False Then Exit Sub
  428.     'Set Hourglass
  429.     Me.MousePointer = vbHourglass
  430.     'Add the dropped data
  431.     For Each varItem In Data.Files
  432.         'Set Temp Item
  433.         strTempPath = CStr(varItem)
  434.         
  435.         'More substantial validation can be done here..but
  436.         'were checking for .wav files only
  437.         If (UCase(Right(strTempPath, 3)) <> "WAV") Then
  438.             MsgBox "Only .wav files are allowed for an audio disc.", vbInformation, App.Title
  439.         Else
  440.             'If is a Directory don't add ...only files
  441.             If IsPathDirectory(strTempPath) = False Then
  442.                 'Insert a track (1 based index)
  443.                 'An insert index of zero will add track to end of track list
  444.                 If CDWriterPro1.InsertAudioTrack(strTempPath, intSelTrack) = False Then
  445.                     MsgBox "Invalid Audio Format...High quality .wav files only!", vbOKOnly + vbInformation
  446.                 End If
  447.                 'Increment The selected track
  448.                 intSelTrack = intSelTrack + 1
  449.             End If
  450.         End If
  451.     Next
  452.     'Reload the track list by enumerating the list
  453.     LoadTrackList
  454.     'Set back Mouse pointer
  455.     Me.MousePointer = vbDefault
  456. End Sub
  457. Private Sub mnuCDRecorderCloseTray_Click()
  458.     Call CDWriterPro1.EjectLoad(True)
  459. End Sub
  460. Private Sub mnuCDRecorderEject_Click()
  461.     Call CDWriterPro1.EjectLoad(False)
  462. End Sub
  463. Private Sub mnuFileClear_Click()
  464.     'Clear the track Queue
  465.     Call CDWriterPro1.ClearAudioTracks
  466.         
  467.     'Clear Track List
  468.     Call lvwAudioTracks.ListItems.Clear
  469. End Sub
  470. Private Sub mnuFileExit_Click()
  471.     Unload Me
  472. End Sub
  473. Private Sub mnuFileRemove_Click()
  474.     'exit if n item is selected
  475.     If lvwAudioTracks.SelectedItem Is Nothing Then Exit Sub
  476.         
  477.     'Remove the track
  478.     Call CDWriterPro1.RemoveAudioTrack(lvwAudioTracks.SelectedItem.Index)
  479.     'Load the list again
  480.     Call LoadTrackList
  481. End Sub
  482. Private Sub mnuHelpAbout_Click()
  483.    ' CDWriterXP1.AboutBox
  484. End Sub
  485. Private Sub LoadDriveCombo()
  486.     Dim lngDrive As Integer
  487.     'Clear Drive Combo
  488.     cboDevices.Clear
  489.     'Default to invalid drive
  490.     mlngCurrentDrive = -1
  491.     'Get the ONLY recordable CD drives (NO DVD ONLY DRIVES)
  492.     For lngDrive = 0 To CDWriterPro1.GetDriveCount() - 1
  493.         
  494.         'Is recorder - all drives are reported not just writers
  495.         'so we need to save the index so we know which drive to open
  496.         'For this audio application, we must make sure that the drives loaded
  497.         'are specifically capable of CD or CDR/W recording..we want to ignore
  498.         'DVD only drives
  499.         If (CDWriterPro1.IsDriveWriter(lngDrive) = True) Then
  500.             cboDevices.AddItem CDWriterPro1.GetDriveLetter(lngDrive) & ": " & CDWriterPro1.GetDriveVendor(lngDrive) & " " & CDWriterPro1.GetDriveModel(lngDrive)
  501.             cboDevices.ItemData(cboDevices.NewIndex) = lngDrive
  502.         End If
  503.     Next
  504.     'Set to first CDR
  505.     If cboDevices.ListCount > 0 Then
  506.         cboDevices.ListIndex = 0
  507.     Else
  508.         MsgBox "There are no compatible CDR drives reported." & vbCrLf & _
  509.                 "Some older CDR drives are not currently supported.", vbInformation + vbOKOnly, App.Title
  510.     End If
  511. End Sub
  512. Private Sub cboDevices_Click()
  513.     Dim lngDriveIndex As Long
  514.     'IMPOTANT: You muist load the index of only the drive indexes saved
  515.     'in the drive combo box
  516.     'Set Drive Index from the Item data which contains the index
  517.     lngDriveIndex = cboDevices.ItemData(cboDevices.ListIndex)
  518.     'Open the Drive for use
  519.     If CDWriterPro1.OpenDrive(lngDriveIndex) = False Then
  520.         mlngCurrentDrive = -1
  521.     Else
  522.         mlngCurrentDrive = lngDriveIndex
  523.     End If
  524.     'Load speeds for this drive
  525.     LoadWriteSpeedCombo
  526.     'Set Burn Proof enabled for checking
  527.     'The use of Burn Proof can lower writing performance speeds,
  528.     'but it will give you a reliable write every time.
  529.     If CDWriterPro1.GetDriveCapabilityFlag(SupportsBurnProof) = True Then
  530.         chkUseBurnProof.Enabled = True
  531.         chkUseBurnProof.Value = vbChecked
  532.     Else
  533.         chkUseBurnProof.Enabled = False
  534.         chkUseBurnProof.Value = vbUnchecked
  535.     End If
  536. End Sub
  537. Private Sub cboWriteSpeed_Click()
  538.     'Check for speeds being available
  539.     If cboWriteSpeed.Text <> "Default" Then
  540.         'Set Drive Speed
  541.         CDWriterPro1.SetWriteSpeed cboWriteSpeed.ItemData(cboWriteSpeed.ListIndex)
  542.     End If
  543. End Sub
  544. Private Sub LoadWriteSpeedCombo()
  545. Dim lngMaxWriteSpeedKBS As Long
  546.     Dim lngSpeedKBS As Long
  547.     Dim dblDisplaySpeed  As Double
  548.     Dim bUseDVDspeeds As Boolean
  549.     Dim DiscType As eMediaType
  550.     'Get Max Write Speed in KB/S not as a multiplier.
  551.     'DVD and CD have different writing rates to calculate multipliers
  552.     'We must use the helper function to determine a multiplier easy for
  553.     'the user to understand
  554.     'What kind of speed multiplier do we need to show the user
  555.     DiscType = CDWriterPro1.GetMediaType()
  556.     If (DiscType = mtCD) Or (DiscType = mtCDRW) Or (DiscType = mtNotLoaded) Then
  557.         'This will be used to calc a multiplier based on KB/s
  558.         bUseDVDspeeds = False
  559.     Else
  560.         bUseDVDspeeds = True
  561.     End If
  562.     'Clear Combo
  563.     cboWriteSpeed.Clear
  564.     'Get the MAX Write speed for the loaded media in kb/s
  565.     lngMaxWriteSpeedKBS = CDWriterPro1.GetMaxWriteSpeed()
  566.     'If speed is not zero then
  567.     If lngMaxWriteSpeedKBS > 0 Then
  568.         
  569.         'Set our temp speed kbs to the max
  570.         lngSpeedKBS = lngMaxWriteSpeedKBS
  571.         
  572.         'DVD speeds or CD speeds for display
  573.         If bUseDVDspeeds = True Then
  574.             Do
  575.                 '1380 is the KB/S constant for DVD for 1X
  576.                 dblDisplaySpeed = CDbl(lngSpeedKBS) / 1380
  577.                 
  578.                 'Calc a displayed Multiplier such as 2.4X for DVD
  579.                 cboWriteSpeed.AddItem Format(dblDisplaySpeed, "#.0") & "x"
  580.                 'Save the Kb/s in the combo
  581.                 cboWriteSpeed.ItemData(cboWriteSpeed.NewIndex) = lngSpeedKBS
  582.                 
  583.                 'For DVD we will increment in .5X levels (eg - 2.4X)
  584.                 lngSpeedKBS = lngSpeedKBS - 690
  585.             Loop While (lngSpeedKBS >= 1380)
  586.         Else
  587.             Do
  588.                 '176kbs is the KB/S constant for CD for 1X
  589.                 dblDisplaySpeed = CDbl(lngSpeedKBS) / 176
  590.                 
  591.                 'Clean up displayed multiplier...some drives report speeds
  592.                 'not in exact multiplies
  593.                 If (dblDisplaySpeed > 0) And (dblDisplaySpeed < 2) Then
  594.                     dblDisplaySpeed = 1
  595.                 End If
  596.                 
  597.                 'Calc a displayed Multiplier such as 16X for CD
  598.                 cboWriteSpeed.AddItem Format(dblDisplaySpeed, "#") & "x"
  599.                 'Save the Kb/s in the combo
  600.                 cboWriteSpeed.ItemData(cboWriteSpeed.NewIndex) = lngSpeedKBS
  601.                 
  602.                 'For CD we will decrement in 2X levels (eg - 8X)
  603.                 'When we hit below 4x, then we decrement in 2X levels
  604.                 If lngSpeedKBS >= 1200 Then
  605.                     lngSpeedKBS = lngSpeedKBS - 704
  606.                 Else
  607.                     lngSpeedKBS = lngSpeedKBS - 352
  608.                 End If
  609.             Loop While (lngSpeedKBS > 0)
  610.         End If
  611.     Else
  612.         'Some drives don't report speed
  613.         cboWriteSpeed.AddItem "Default"
  614.     End If
  615.     'Set to Max
  616.     If cboWriteSpeed.ListCount > 0 Then
  617.         cboWriteSpeed.ListIndex = 0
  618.     End If
  619.         
  620. End Sub
  621. Private Function IsPathDirectory(strPath As String) As Boolean
  622.     If (GetAttr(strPath) And vbDirectory) = vbDirectory Then
  623.         IsPathDirectory = True
  624.     Else
  625.         IsPathDirectory = False
  626.     End If
  627. End Function
  628. Private Sub LoadTrackList()
  629.     Dim lngDiscFreeSpace As Long
  630.     Dim lngTotalDiscLengthBlocks As Long
  631.     'Get the track count and free space on the disc
  632.     mintTracksToWrite = CDWriterPro1.GetAudioTrackCount()
  633.     'Get the Free Space of the disk if a drive is selected
  634.     If mlngCurrentDrive <> -1 Then
  635.         lngDiscFreeSpace = CDWriterPro1.GetDiscFreeSpaceBlocks()
  636.     End If
  637.     'Clear the List
  638.     lvwAudioTracks.ListItems.Clear
  639.     'Enumerate Tracks - makes it easy to update your list
  640.     Call CDWriterPro1.EnumerateAudioTracks
  641.     'Get the total Audio Volume Size
  642.     lngTotalDiscLengthBlocks = CDWriterPro1.GetAudioVolumeSizeBlocks()
  643.     'Set the Total disc space used
  644.     sbrStatus.SimpleText = CDWriterPro1.ConvertBlocksToMSFString(lngTotalDiscLengthBlocks) & " of " & CDWriterPro1.ConvertBlocksToMSFString(lngDiscFreeSpace) & " Used"
  645.     'Set number of tracks to write
  646.     mintTracksToWrite = CDWriterPro1.GetAudioTrackCount()
  647. End Sub
  648. Private Sub EnableForm(blnEnable As Boolean)
  649.     'Disable buttons and track view when recording
  650.     mnuFile.Enabled = blnEnable
  651.     mnuCDRecorder.Enabled = blnEnable
  652.     mnuHelp.Enabled = blnEnable
  653.     cboDevices.Enabled = blnEnable
  654.     cboWriteSpeed.Enabled = blnEnable
  655.     lvwAudioTracks.Enabled = blnEnable
  656.     cmdWriteDisc.Enabled = blnEnable
  657.     chkCacheFiles.Enabled = blnEnable
  658.     chkTestWrite.Enabled = blnEnable
  659.      'Enable the burn Proof checkbox
  660.     If (CDWriterPro1.GetDriveCapabilityFlag(SupportsBurnProof) = True) And (blnEnable = True) Then
  661.         chkUseBurnProof.Enabled = True
  662.     Else
  663.         chkUseBurnProof.Enabled = False
  664.     End If
  665.     'Only enable when recording
  666.     cmdCancel.Enabled = Not blnEnable
  667.     mblnUnloadOk = blnEnable
  668.     'Set Pointer
  669.     If blnEnable = True Then
  670.         Me.MousePointer = vbDefault
  671.     Else
  672.         Me.MousePointer = vbHourglass
  673.     End If
  674. End Sub
  675.