home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / activex / demos / oletrial / samples / vb / mhalrm / props.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-11-30  |  15.2 KB  |  415 lines

  1. VERSION 4.00
  2. Begin VB.Form frmMhAlarmPropertyTester 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Properties"
  5.    ClientHeight    =   3048
  6.    ClientLeft      =   2016
  7.    ClientTop       =   2304
  8.    ClientWidth     =   4848
  9.    Height          =   3420
  10.    Icon            =   "PROPS.frx":0000
  11.    Left            =   1968
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3048
  16.    ScaleWidth      =   4848
  17.    ShowInTaskbar   =   0   'False
  18.    Top             =   1980
  19.    Width           =   4944
  20.    Begin VB.CommandButton cmdOkCancelApply 
  21.       Caption         =   "&Apply"
  22.       Enabled         =   0   'False
  23.       Height          =   372
  24.       Index           =   2
  25.       Left            =   3528
  26.       TabIndex        =   8
  27.       Top             =   2556
  28.       Width           =   1212
  29.    End
  30.    Begin VB.CommandButton cmdOkCancelApply 
  31.       Cancel          =   -1  'True
  32.       Caption         =   "&Cancel"
  33.       Height          =   372
  34.       Index           =   1
  35.       Left            =   2232
  36.       TabIndex        =   7
  37.       Top             =   2556
  38.       Width           =   1212
  39.    End
  40.    Begin VB.CommandButton cmdOkCancelApply 
  41.       Caption         =   "OK"
  42.       Default         =   -1  'True
  43.       Height          =   372
  44.       Index           =   0
  45.       Left            =   936
  46.       TabIndex        =   6
  47.       Top             =   2556
  48.       Width           =   1212
  49.    End
  50.    Begin Threed.SSPanel SSPanel1 
  51.       Height          =   2352
  52.       Left            =   108
  53.       TabIndex        =   9
  54.       Top             =   108
  55.       Width           =   4620
  56.       _Version        =   65536
  57.       _ExtentX        =   8149
  58.       _ExtentY        =   4149
  59.       _StockProps     =   15
  60.       Begin VB.Frame Frame2 
  61.          Caption         =   "&Wave File"
  62.          Height          =   1056
  63.          Left            =   144
  64.          TabIndex        =   12
  65.          Top             =   1116
  66.          Width           =   4296
  67.          Begin VB.CheckBox chkUseInternalResource 
  68.             Caption         =   "Use &Internal Resources"
  69.             Height          =   228
  70.             Left            =   1512
  71.             TabIndex        =   4
  72.             Top             =   324
  73.             Width           =   2568
  74.          End
  75.          Begin VB.TextBox txtPath 
  76.             Alignment       =   1  'Right Justify
  77.             Height          =   288
  78.             Left            =   180
  79.             Locked          =   -1  'True
  80.             TabIndex        =   5
  81.             Top             =   648
  82.             Width           =   3936
  83.          End
  84.          Begin VB.CommandButton cmdPath 
  85.             Caption         =   "&Path..."
  86.             Height          =   288
  87.             Left            =   180
  88.             TabIndex        =   3
  89.             Top             =   288
  90.             Width           =   1212
  91.          End
  92.       End
  93.       Begin VB.Frame Frame3 
  94.          Height          =   948
  95.          Left            =   2340
  96.          TabIndex        =   11
  97.          Top             =   144
  98.          Width           =   2100
  99.          Begin VB.CommandButton cmdTest 
  100.             Caption         =   "Compa&re"
  101.             Height          =   264
  102.             Index           =   1
  103.             Left            =   756
  104.             TabIndex        =   2
  105.             Top             =   540
  106.             Width           =   1212
  107.          End
  108.          Begin VB.CommandButton cmdTest 
  109.             Caption         =   "&Test"
  110.             Height          =   264
  111.             Index           =   0
  112.             Left            =   756
  113.             TabIndex        =   1
  114.             Top             =   252
  115.             Width           =   1212
  116.          End
  117.          Begin Mhal200Lib.MhIAlarm MhIAlarmTest 
  118.             Height          =   384
  119.             Left            =   180
  120.             TabIndex        =   14
  121.             TabStop         =   0   'False
  122.             Top             =   360
  123.             Width           =   384
  124.             _Version        =   65536
  125.             _ExtentX        =   677
  126.             _ExtentY        =   677
  127.             _StockProps     =   65
  128.             TintColor       =   16711935
  129.             Style           =   0
  130.             Autosize        =   -1  'True
  131.             RingTime        =   0
  132.             PauseTime       =   0
  133.             RingTone        =   0
  134.             RingMode        =   0
  135.             RingLength      =   0
  136.             RingOn          =   0
  137.             WaveSource      =   0
  138.             Interval        =   250
  139.             WindowState     =   0
  140.             PictureMask1    =   "PROPS.frx":0442
  141.             PictureMask2    =   "PROPS.frx":045E
  142.             PictureMask3    =   "PROPS.frx":047A
  143.             Picture1        =   "PROPS.frx":0496
  144.             Picture2        =   "PROPS.frx":04B2
  145.             Picture3        =   "PROPS.frx":04CE
  146.             WaveName        =   "Telephone"
  147.          End
  148.       End
  149.       Begin VB.Frame Frame1 
  150.          Caption         =   "&Style"
  151.          Height          =   948
  152.          Left            =   144
  153.          TabIndex        =   10
  154.          Top             =   144
  155.          Width           =   2100
  156.          Begin VB.ComboBox cboStyle 
  157.             Height          =   288
  158.             Left            =   144
  159.             Style           =   2  'Dropdown List
  160.             TabIndex        =   0
  161.             Top             =   396
  162.             Width           =   1776
  163.          End
  164.       End
  165.    End
  166.    Begin MhcommdlLib.MhCommonDialog MhCommonDialogDemo 
  167.       Height          =   336
  168.       Left            =   504
  169.       TabIndex        =   13
  170.       TabStop         =   0   'False
  171.       Top             =   2592
  172.       Width           =   336
  173.       _Version        =   65536
  174.       _ExtentX        =   593
  175.       _ExtentY        =   593
  176.       _StockProps     =   4
  177.       TintColor       =   16711935
  178.       Filename        =   ""
  179.       DialogTop       =   0
  180.       DialogLeft      =   0
  181.       DialogWidth     =   0
  182.       DialogHeight    =   0
  183.       InitDir         =   ""
  184.       Filter          =   ""
  185.       DefaultExt      =   ""
  186.       DialogTitle     =   ""
  187.       FilterIndex     =   0
  188.       Flags           =   0
  189.       CancelError     =   0   'False
  190.       MaxFileSize     =   256
  191.       Color           =   0
  192.       Max             =   0
  193.       Min             =   0
  194.       Copies          =   0
  195.       FromPage        =   0
  196.       PrinterDefault  =   -1  'True
  197.       ToPage          =   0
  198.       HelpCommand     =   0
  199.       HelpContext     =   0
  200.       HelpFile        =   ""
  201.       HelpKey         =   ""
  202.    End
  203. Attribute VB_Name = "frmMhAlarmPropertyTester"
  204. Attribute VB_Creatable = False
  205. Attribute VB_Exposed = False
  206. Option Explicit ' always
  207. ' private properties
  208. Private m_oParent As Object
  209. Private m_sWaveName As String, m_iWaveSource As Byte
  210. ' public properties
  211. Public OriginalAlarm As Mhal200Lib.MhIAlarm ' used to let form objects know which alarm to work on
  212. Public Property Set ParentObject(NewParentObject As Object)
  213.     ' sets object which is the parent of this form object
  214.     Set m_oParent = NewParentObject
  215. End Property
  216. Public Property Get ParentObject() As Object
  217.     ' return the object which is this form's parent
  218.     Set ParentObject = m_oParent
  219. End Property
  220. Private Sub cboStyle_Click()
  221.     ' update the style of the test alarm
  222.     MhIAlarmTest.Style = cboStyle.ListIndex
  223.     ' since the control defaults some properties when the style is switched
  224.     '   set the control to current settings
  225.     'MhIAlarmTest.WaveSource = m_iWaveSource
  226.     ' change to internal resource
  227.     chkUseInternalResource.Value = vbChecked
  228.     ' enable the apply button
  229.     cmdOkCancelApply(2).Enabled = True
  230. End Sub
  231. Private Sub chkUseInternalResource_Click()
  232.     If chkUseInternalResource.Value = vbChecked Then
  233.         m_iWaveSource = 0 ' internal resource
  234.         ' show user that internal file will be used
  235.         txtPath.Enabled = False
  236.         txtPath = "<Internal Resource>"
  237.         Select Case MhIAlarmTest.Style
  238.         Case 0 ' telephone
  239.             MhIAlarmTest.WaveName = "Telephone"
  240.         Case 1
  241.             MhIAlarmTest.WaveName = "AlarmClock"
  242.         Case 2
  243.             MhIAlarmTest.WaveName = "Wristwatch"
  244.         End Select
  245.     Else
  246.         m_iWaveSource = 2 ' wave file
  247.         MhIAlarmTest.WaveName = m_sWaveName
  248.         txtPath.Enabled = True
  249.         ' show user that wave file will be used
  250.         txtPath = m_sWaveName
  251.         ' if there is no wave file specified then show the open file dialog
  252.         If Trim$(m_sWaveName) = "" Then Call cmdPath_Click
  253.     End If
  254.     ' enable the apply button
  255.     cmdOkCancelApply(2).Enabled = True
  256. End Sub
  257. Private Sub cmdOkCancelApply_Click(Index As Integer)
  258.     Select Case Index
  259.     Case 0, 2 ' ok or apply button pressed so apply changes
  260.         ' set the properties of the current alarm control to match those of the test alarm
  261.         OriginalAlarm.Style = MhIAlarmTest.Style
  262.         OriginalAlarm.WaveName = MhIAlarmTest.WaveName
  263.         OriginalAlarm.WaveSource = MhIAlarmTest.WaveSource
  264.     Case 1 ' cancel
  265.     End Select
  266.     ' if the user hit the apply button the turn it off since the changes have been applied
  267.     '   otherwise unload the form since the user hit cancel or ok
  268.     If Index = 2 Then ' turn apply button off
  269.         cmdOkCancelApply(2).Enabled = False
  270.     Else
  271.         Unload Me
  272.     End If
  273. End Sub
  274. Private Sub cmdTest_Click(Index As Integer)
  275.     Select Case Index
  276.     Case 0 ' test/stop
  277.         Select Case cmdTest(0).Caption
  278.         Case "&Test"
  279.             ' ring the test alarm
  280.             MhIAlarmTest.RingOn = 2
  281.             cmdTest(0).Caption = "Stop"
  282.             'disable the 'compare' button
  283.             cmdTest(1).Enabled = False
  284.         Case "Stop"
  285.             ' stop the test alarm from ringing
  286.             MhIAlarmTest.RingOn = 0
  287.             cmdTest(0).Caption = "&Test"
  288.             'reenable the 'compare' button
  289.             cmdTest(1).Enabled = True
  290.         End Select
  291.     Case 1 ' compare
  292.         ' fire the original alarm then test alarm to give the user a comparison
  293.         OriginalAlarm.RingOn = 1
  294.         ' disable form while this is going on so that the user does not trigger another event
  295.         Me.Enabled = False
  296.         Do Until OriginalAlarm.RingOn = 0
  297.             DoEvents
  298.         Loop
  299.         Me.Enabled = True
  300.         MhIAlarmTest.RingOn = 1
  301.     End Select
  302. End Sub
  303. Private Sub Form_Load()
  304.     ' fill the combo with valid alarm styles
  305.     cboStyle.AddItem "Telephone"
  306.     cboStyle.AddItem "Alarm Clock"
  307.     cboStyle.AddItem "Wrist Watch"
  308.     ' update the form with the properties of the current alarm
  309.     Style = OriginalAlarm.Style
  310.     WaveSource = OriginalAlarm.WaveSource
  311.     MhIAlarmTest.WaveSource = OriginalAlarm.WaveSource
  312.     MhIAlarmTest.WaveName = OriginalAlarm.WaveName
  313.     ' place this form at top left of screen so that it will not obscure the form from which it was launched
  314.     Me.Top = 0
  315.     Me.Left = 0
  316.     ' disable the apply button (until the user makes changes which need to be applied)
  317.     cmdOkCancelApply(2).Enabled = False
  318. End Sub
  319. Public Property Let WaveName(sNewValue As String)
  320.     ' update text box with the new value
  321.     m_sWaveName = sNewValue
  322.     txtPath = m_sWaveName
  323. End Property
  324. Public Property Let WaveSource(iNewValue As Byte)
  325.     m_iWaveSource = iNewValue
  326.     ' update check box with the new value
  327.     If m_iWaveSource = 0 Then 'internal resource
  328.         chkUseInternalResource.Value = vbChecked
  329.     Else
  330.         chkUseInternalResource.Value = vbUnchecked
  331.     End If
  332. End Property
  333. Public Property Get Style() As Integer
  334.     ' return the setting of the combo box
  335.     Style = cboStyle.ListIndex
  336. End Property
  337. Public Property Let Style(iNewValue As Integer)
  338.     ' update the combo box with the new value
  339.     cboStyle.ListIndex = iNewValue
  340. End Property
  341. Private Function ShowFileDialog(sFileToUse As String, Optional vDialogTitle As Variant, Optional vFlags As Variant, _
  342.                                                                 Optional vFilter As Variant) As Boolean
  343. On Error GoTo ShowFileDialog_Error
  344.     Static iSelectedFilterIndex As Byte ' used to remember the last type of filter the user selected
  345.     Dim bDialogCanceled As Boolean ' indicates that the dialog box has been canceled
  346.     With MhCommonDialogDemo
  347.         ' do this so that we can tell if the user hit the cancel button (error cdlCancel is raised)
  348.         .CancelError = True
  349.         ' set the types of files which will appear in the 'filter' combo box
  350.         .Filter = vFilter
  351.         ' if the calling routine passed a filename then make it the default
  352.         If sFileToUse <> "" Then .filename = sFileToUse
  353.         ' select the type of 'filter' that the user used last time, if this is the first time then just select the first filter
  354.         If iSelectedFilterIndex <> 0 Then
  355.             .FilterIndex = iSelectedFilterIndex
  356.         Else
  357.             .FilterIndex = 1
  358.         End If
  359.         
  360.         ' set the title if the calling procedure specified one otherwise set a default one
  361.         If Not IsMissing(vDialogTitle) Then
  362.             .DialogTitle = vDialogTitle
  363.         Else
  364.             .DialogTitle = "Open"
  365.         End If
  366.         ' set the .Flags property if the calling procedure set the vFlags parameter
  367.         If Not IsMissing(vFlags) Then .Flags = vFlags
  368.         ' show 'open file' dialog
  369.         .Action = 1
  370.         
  371.         ' remember last filter type used
  372.         iSelectedFilterIndex = .FilterIndex
  373.         
  374.         ' if the dialog was not canceled then set the file and return True for the function
  375.         If Not bDialogCanceled Then
  376.             ' get the file name from the dialog
  377.             sFileToUse = Trim$(.filename)
  378.             ShowFileDialog = True
  379.         Else
  380.             ' dialog canceled so return False for the function
  381.             ShowFileDialog = False
  382.         End If
  383.         
  384.     End With ' MhCommonDialogDemo
  385. Exit Function
  386. ShowFileDialog_Error:
  387. Select Case Err.Number
  388. Case cdlCancel ' the user hit the cancel button in the 'open file' dialog
  389.     bDialogCanceled = True
  390. End Select
  391. Resume Next
  392. End Function
  393. Private Sub cmdPath_Click()
  394.     ' set the path of the .WaveName property of the MhIAlarmTest control
  395.     Dim sFileToUse As String, sDialogTitle As String
  396.     Dim iFlags As Integer, sFilter As String
  397.     iFlags = cdlOFNFileMustExist + cdlOFNPathMustExist + cdlOFNHideReadOnly
  398.     sDialogTitle = "Load .Wav File"
  399.     sFilter = "Wav Files|*.wav"
  400.     ' if the dialog was not canceled then load the file
  401.     If ShowFileDialog(sFileToUse, sDialogTitle, iFlags, sFilter) Then
  402.         '' set the new file
  403.         WaveName = sFileToUse
  404.         WaveSource = 2 ' wave file
  405.         ' update the test alarm
  406.         With MhIAlarmTest
  407.             .Style = Me.Style
  408.             .WaveName = m_sWaveName
  409.             .WaveSource = m_iWaveSource
  410.         End With ' MhIAlarmTest
  411.         ' enable the apply button
  412.         cmdOkCancelApply(2).Enabled = True
  413.     End If
  414. End Sub
  415.