home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form frmMhAlarmPropertyTester
- BorderStyle = 3 'Fixed Dialog
- Caption = "Properties"
- ClientHeight = 3048
- ClientLeft = 2016
- ClientTop = 2304
- ClientWidth = 4848
- Height = 3420
- Icon = "PROPS.frx":0000
- Left = 1968
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 3048
- ScaleWidth = 4848
- ShowInTaskbar = 0 'False
- Top = 1980
- Width = 4944
- Begin VB.CommandButton cmdOkCancelApply
- Caption = "&Apply"
- Enabled = 0 'False
- Height = 372
- Index = 2
- Left = 3528
- TabIndex = 8
- Top = 2556
- Width = 1212
- End
- Begin VB.CommandButton cmdOkCancelApply
- Cancel = -1 'True
- Caption = "&Cancel"
- Height = 372
- Index = 1
- Left = 2232
- TabIndex = 7
- Top = 2556
- Width = 1212
- End
- Begin VB.CommandButton cmdOkCancelApply
- Caption = "OK"
- Default = -1 'True
- Height = 372
- Index = 0
- Left = 936
- TabIndex = 6
- Top = 2556
- Width = 1212
- End
- Begin Threed.SSPanel SSPanel1
- Height = 2352
- Left = 108
- TabIndex = 9
- Top = 108
- Width = 4620
- _Version = 65536
- _ExtentX = 8149
- _ExtentY = 4149
- _StockProps = 15
- Begin VB.Frame Frame2
- Caption = "&Wave File"
- Height = 1056
- Left = 144
- TabIndex = 12
- Top = 1116
- Width = 4296
- Begin VB.CheckBox chkUseInternalResource
- Caption = "Use &Internal Resources"
- Height = 228
- Left = 1512
- TabIndex = 4
- Top = 324
- Width = 2568
- End
- Begin VB.TextBox txtPath
- Alignment = 1 'Right Justify
- Height = 288
- Left = 180
- Locked = -1 'True
- TabIndex = 5
- Top = 648
- Width = 3936
- End
- Begin VB.CommandButton cmdPath
- Caption = "&Path..."
- Height = 288
- Left = 180
- TabIndex = 3
- Top = 288
- Width = 1212
- End
- End
- Begin VB.Frame Frame3
- Height = 948
- Left = 2340
- TabIndex = 11
- Top = 144
- Width = 2100
- Begin VB.CommandButton cmdTest
- Caption = "Compa&re"
- Height = 264
- Index = 1
- Left = 756
- TabIndex = 2
- Top = 540
- Width = 1212
- End
- Begin VB.CommandButton cmdTest
- Caption = "&Test"
- Height = 264
- Index = 0
- Left = 756
- TabIndex = 1
- Top = 252
- Width = 1212
- End
- Begin Mhal200Lib.MhIAlarm MhIAlarmTest
- Height = 384
- Left = 180
- TabIndex = 14
- TabStop = 0 'False
- Top = 360
- Width = 384
- _Version = 65536
- _ExtentX = 677
- _ExtentY = 677
- _StockProps = 65
- TintColor = 16711935
- Style = 0
- Autosize = -1 'True
- RingTime = 0
- PauseTime = 0
- RingTone = 0
- RingMode = 0
- RingLength = 0
- RingOn = 0
- WaveSource = 0
- Interval = 250
- WindowState = 0
- PictureMask1 = "PROPS.frx":0442
- PictureMask2 = "PROPS.frx":045E
- PictureMask3 = "PROPS.frx":047A
- Picture1 = "PROPS.frx":0496
- Picture2 = "PROPS.frx":04B2
- Picture3 = "PROPS.frx":04CE
- WaveName = "Telephone"
- End
- End
- Begin VB.Frame Frame1
- Caption = "&Style"
- Height = 948
- Left = 144
- TabIndex = 10
- Top = 144
- Width = 2100
- Begin VB.ComboBox cboStyle
- Height = 288
- Left = 144
- Style = 2 'Dropdown List
- TabIndex = 0
- Top = 396
- Width = 1776
- End
- End
- End
- Begin MhcommdlLib.MhCommonDialog MhCommonDialogDemo
- Height = 336
- Left = 504
- TabIndex = 13
- TabStop = 0 'False
- Top = 2592
- Width = 336
- _Version = 65536
- _ExtentX = 593
- _ExtentY = 593
- _StockProps = 4
- TintColor = 16711935
- Filename = ""
- DialogTop = 0
- DialogLeft = 0
- DialogWidth = 0
- DialogHeight = 0
- InitDir = ""
- Filter = ""
- DefaultExt = ""
- DialogTitle = ""
- FilterIndex = 0
- Flags = 0
- CancelError = 0 'False
- MaxFileSize = 256
- Color = 0
- Max = 0
- Min = 0
- Copies = 0
- FromPage = 0
- PrinterDefault = -1 'True
- ToPage = 0
- HelpCommand = 0
- HelpContext = 0
- HelpFile = ""
- HelpKey = ""
- End
- Attribute VB_Name = "frmMhAlarmPropertyTester"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit ' always
- ' private properties
- Private m_oParent As Object
- Private m_sWaveName As String, m_iWaveSource As Byte
- ' public properties
- Public OriginalAlarm As Mhal200Lib.MhIAlarm ' used to let form objects know which alarm to work on
- Public Property Set ParentObject(NewParentObject As Object)
- ' sets object which is the parent of this form object
- Set m_oParent = NewParentObject
- End Property
- Public Property Get ParentObject() As Object
- ' return the object which is this form's parent
- Set ParentObject = m_oParent
- End Property
- Private Sub cboStyle_Click()
- ' update the style of the test alarm
- MhIAlarmTest.Style = cboStyle.ListIndex
- ' since the control defaults some properties when the style is switched
- ' set the control to current settings
- 'MhIAlarmTest.WaveSource = m_iWaveSource
- ' change to internal resource
- chkUseInternalResource.Value = vbChecked
- ' enable the apply button
- cmdOkCancelApply(2).Enabled = True
- End Sub
- Private Sub chkUseInternalResource_Click()
- If chkUseInternalResource.Value = vbChecked Then
- m_iWaveSource = 0 ' internal resource
- ' show user that internal file will be used
- txtPath.Enabled = False
- txtPath = "<Internal Resource>"
- Select Case MhIAlarmTest.Style
- Case 0 ' telephone
- MhIAlarmTest.WaveName = "Telephone"
- Case 1
- MhIAlarmTest.WaveName = "AlarmClock"
- Case 2
- MhIAlarmTest.WaveName = "Wristwatch"
- End Select
- Else
- m_iWaveSource = 2 ' wave file
- MhIAlarmTest.WaveName = m_sWaveName
- txtPath.Enabled = True
- ' show user that wave file will be used
- txtPath = m_sWaveName
- ' if there is no wave file specified then show the open file dialog
- If Trim$(m_sWaveName) = "" Then Call cmdPath_Click
- End If
- ' enable the apply button
- cmdOkCancelApply(2).Enabled = True
- End Sub
- Private Sub cmdOkCancelApply_Click(Index As Integer)
- Select Case Index
- Case 0, 2 ' ok or apply button pressed so apply changes
- ' set the properties of the current alarm control to match those of the test alarm
- OriginalAlarm.Style = MhIAlarmTest.Style
- OriginalAlarm.WaveName = MhIAlarmTest.WaveName
- OriginalAlarm.WaveSource = MhIAlarmTest.WaveSource
- Case 1 ' cancel
- End Select
- ' if the user hit the apply button the turn it off since the changes have been applied
- ' otherwise unload the form since the user hit cancel or ok
- If Index = 2 Then ' turn apply button off
- cmdOkCancelApply(2).Enabled = False
- Else
- Unload Me
- End If
- End Sub
- Private Sub cmdTest_Click(Index As Integer)
- Select Case Index
- Case 0 ' test/stop
- Select Case cmdTest(0).Caption
- Case "&Test"
- ' ring the test alarm
- MhIAlarmTest.RingOn = 2
- cmdTest(0).Caption = "Stop"
- 'disable the 'compare' button
- cmdTest(1).Enabled = False
- Case "Stop"
- ' stop the test alarm from ringing
- MhIAlarmTest.RingOn = 0
- cmdTest(0).Caption = "&Test"
- 'reenable the 'compare' button
- cmdTest(1).Enabled = True
- End Select
- Case 1 ' compare
- ' fire the original alarm then test alarm to give the user a comparison
- OriginalAlarm.RingOn = 1
- ' disable form while this is going on so that the user does not trigger another event
- Me.Enabled = False
- Do Until OriginalAlarm.RingOn = 0
- DoEvents
- Loop
- Me.Enabled = True
- MhIAlarmTest.RingOn = 1
- End Select
- End Sub
- Private Sub Form_Load()
- ' fill the combo with valid alarm styles
- cboStyle.AddItem "Telephone"
- cboStyle.AddItem "Alarm Clock"
- cboStyle.AddItem "Wrist Watch"
- ' update the form with the properties of the current alarm
- Style = OriginalAlarm.Style
- WaveSource = OriginalAlarm.WaveSource
- MhIAlarmTest.WaveSource = OriginalAlarm.WaveSource
- MhIAlarmTest.WaveName = OriginalAlarm.WaveName
- ' place this form at top left of screen so that it will not obscure the form from which it was launched
- Me.Top = 0
- Me.Left = 0
- ' disable the apply button (until the user makes changes which need to be applied)
- cmdOkCancelApply(2).Enabled = False
- End Sub
- Public Property Let WaveName(sNewValue As String)
- ' update text box with the new value
- m_sWaveName = sNewValue
- txtPath = m_sWaveName
- End Property
- Public Property Let WaveSource(iNewValue As Byte)
- m_iWaveSource = iNewValue
- ' update check box with the new value
- If m_iWaveSource = 0 Then 'internal resource
- chkUseInternalResource.Value = vbChecked
- Else
- chkUseInternalResource.Value = vbUnchecked
- End If
- End Property
- Public Property Get Style() As Integer
- ' return the setting of the combo box
- Style = cboStyle.ListIndex
- End Property
- Public Property Let Style(iNewValue As Integer)
- ' update the combo box with the new value
- cboStyle.ListIndex = iNewValue
- End Property
- Private Function ShowFileDialog(sFileToUse As String, Optional vDialogTitle As Variant, Optional vFlags As Variant, _
- Optional vFilter As Variant) As Boolean
- On Error GoTo ShowFileDialog_Error
- Static iSelectedFilterIndex As Byte ' used to remember the last type of filter the user selected
- Dim bDialogCanceled As Boolean ' indicates that the dialog box has been canceled
- With MhCommonDialogDemo
- ' do this so that we can tell if the user hit the cancel button (error cdlCancel is raised)
- .CancelError = True
- ' set the types of files which will appear in the 'filter' combo box
- .Filter = vFilter
- ' if the calling routine passed a filename then make it the default
- If sFileToUse <> "" Then .filename = sFileToUse
- ' select the type of 'filter' that the user used last time, if this is the first time then just select the first filter
- If iSelectedFilterIndex <> 0 Then
- .FilterIndex = iSelectedFilterIndex
- Else
- .FilterIndex = 1
- End If
-
- ' set the title if the calling procedure specified one otherwise set a default one
- If Not IsMissing(vDialogTitle) Then
- .DialogTitle = vDialogTitle
- Else
- .DialogTitle = "Open"
- End If
- ' set the .Flags property if the calling procedure set the vFlags parameter
- If Not IsMissing(vFlags) Then .Flags = vFlags
- ' show 'open file' dialog
- .Action = 1
-
- ' remember last filter type used
- iSelectedFilterIndex = .FilterIndex
-
- ' if the dialog was not canceled then set the file and return True for the function
- If Not bDialogCanceled Then
- ' get the file name from the dialog
- sFileToUse = Trim$(.filename)
- ShowFileDialog = True
- Else
- ' dialog canceled so return False for the function
- ShowFileDialog = False
- End If
-
- End With ' MhCommonDialogDemo
- Exit Function
- ShowFileDialog_Error:
- Select Case Err.Number
- Case cdlCancel ' the user hit the cancel button in the 'open file' dialog
- bDialogCanceled = True
- End Select
- Resume Next
- End Function
- Private Sub cmdPath_Click()
- ' set the path of the .WaveName property of the MhIAlarmTest control
- Dim sFileToUse As String, sDialogTitle As String
- Dim iFlags As Integer, sFilter As String
- iFlags = cdlOFNFileMustExist + cdlOFNPathMustExist + cdlOFNHideReadOnly
- sDialogTitle = "Load .Wav File"
- sFilter = "Wav Files|*.wav"
- ' if the dialog was not canceled then load the file
- If ShowFileDialog(sFileToUse, sDialogTitle, iFlags, sFilter) Then
- '' set the new file
- WaveName = sFileToUse
- WaveSource = 2 ' wave file
- ' update the test alarm
- With MhIAlarmTest
- .Style = Me.Style
- .WaveName = m_sWaveName
- .WaveSource = m_iWaveSource
- End With ' MhIAlarmTest
- ' enable the apply button
- cmdOkCancelApply(2).Enabled = True
- End If
- End Sub
-