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

  1. VERSION 4.00
  2. Begin VB.Form frmMhWaveOCX_Demo 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "MicroHelp MhWave OCX Demo"
  5.    ClientHeight    =   3720
  6.    ClientLeft      =   2040
  7.    ClientTop       =   2064
  8.    ClientWidth     =   5568
  9.    BeginProperty Font 
  10.       name            =   "MS Sans Serif"
  11.       charset         =   0
  12.       weight          =   700
  13.       size            =   7.8
  14.       underline       =   0   'False
  15.       italic          =   0   'False
  16.       strikethrough   =   0   'False
  17.    EndProperty
  18.    ForeColor       =   &H80000008&
  19.    Height          =   4332
  20.    Icon            =   "Mhwave.frx":0000
  21.    Left            =   1992
  22.    LinkTopic       =   "Form1"
  23.    ScaleHeight     =   3720
  24.    ScaleWidth      =   5568
  25.    Top             =   1500
  26.    Width           =   5664
  27.    Begin VB.Frame fraBuiltInWaves 
  28.       Caption         =   "The MhWave Control Has Built In Sounds For..."
  29.       Height          =   2712
  30.       Left            =   5652
  31.       TabIndex        =   22
  32.       Tag             =   "slide frame"
  33.       Top             =   72
  34.       Width           =   5412
  35.       Begin VB.Frame Frame3 
  36.          Caption         =   "And Numbers."
  37.          Height          =   948
  38.          Left            =   180
  39.          TabIndex        =   27
  40.          Top             =   1620
  41.          Width           =   5052
  42.          Begin VB.CommandButton cmdPlayNumber 
  43.             Caption         =   "100"
  44.             BeginProperty Font 
  45.                name            =   "MS Sans Serif"
  46.                charset         =   0
  47.                weight          =   400
  48.                size            =   7.8
  49.                underline       =   0   'False
  50.                italic          =   0   'False
  51.                strikethrough   =   0   'False
  52.             EndProperty
  53.             Height          =   372
  54.             Index           =   3
  55.             Left            =   3744
  56.             TabIndex        =   12
  57.             Top             =   396
  58.             Width           =   1176
  59.          End
  60.          Begin VB.CommandButton cmdPlayNumber 
  61.             Caption         =   "95555255225"
  62.             BeginProperty Font 
  63.                name            =   "MS Sans Serif"
  64.                charset         =   0
  65.                weight          =   400
  66.                size            =   7.8
  67.                underline       =   0   'False
  68.                italic          =   0   'False
  69.                strikethrough   =   0   'False
  70.             EndProperty
  71.             Height          =   372
  72.             Index           =   2
  73.             Left            =   2556
  74.             TabIndex        =   11
  75.             Top             =   396
  76.             Width           =   1176
  77.          End
  78.          Begin VB.CommandButton cmdPlayNumber 
  79.             Caption         =   "0.2543"
  80.             BeginProperty Font 
  81.                name            =   "MS Sans Serif"
  82.                charset         =   0
  83.                weight          =   400
  84.                size            =   7.8
  85.                underline       =   0   'False
  86.                italic          =   0   'False
  87.                strikethrough   =   0   'False
  88.             EndProperty
  89.             Height          =   372
  90.             Index           =   1
  91.             Left            =   1368
  92.             TabIndex        =   10
  93.             Top             =   396
  94.             Width           =   1176
  95.          End
  96.          Begin VB.CommandButton cmdPlayNumber 
  97.             Caption         =   "123.66764"
  98.             BeginProperty Font 
  99.                name            =   "MS Sans Serif"
  100.                charset         =   0
  101.                weight          =   400
  102.                size            =   7.8
  103.                underline       =   0   'False
  104.                italic          =   0   'False
  105.                strikethrough   =   0   'False
  106.             EndProperty
  107.             Height          =   372
  108.             Index           =   0
  109.             Left            =   180
  110.             TabIndex        =   9
  111.             Top             =   396
  112.             Width           =   1176
  113.          End
  114.       End
  115.       Begin VB.Frame Frame2 
  116.          Caption         =   "Dollar Amounts,"
  117.          Height          =   1236
  118.          Left            =   2628
  119.          TabIndex        =   26
  120.          Top             =   324
  121.          Width           =   2604
  122.          Begin VB.CommandButton cmdPlayDollarAmount 
  123.             Caption         =   "$189.95"
  124.             BeginProperty Font 
  125.                name            =   "MS Sans Serif"
  126.                charset         =   0
  127.                weight          =   400
  128.                size            =   7.8
  129.                underline       =   0   'False
  130.                italic          =   0   'False
  131.                strikethrough   =   0   'False
  132.             EndProperty
  133.             Height          =   372
  134.             Index           =   1
  135.             Left            =   684
  136.             TabIndex        =   8
  137.             Top             =   720
  138.             Width           =   1212
  139.          End
  140.          Begin VB.CommandButton cmdPlayDollarAmount 
  141.             Caption         =   "$1,000,000"
  142.             BeginProperty Font 
  143.                name            =   "MS Sans Serif"
  144.                charset         =   0
  145.                weight          =   400
  146.                size            =   7.8
  147.                underline       =   0   'False
  148.                italic          =   0   'False
  149.                strikethrough   =   0   'False
  150.             EndProperty
  151.             Height          =   372
  152.             Index           =   0
  153.             Left            =   684
  154.             TabIndex        =   7
  155.             Top             =   324
  156.             Width           =   1212
  157.          End
  158.       End
  159.       Begin VB.Frame Frame1 
  160.          Caption         =   "Dates,"
  161.          Height          =   1236
  162.          Left            =   180
  163.          TabIndex        =   25
  164.          Top             =   324
  165.          Width           =   2316
  166.          Begin VB.CommandButton cmdPlayDate 
  167.             Caption         =   "&Yesterday"
  168.             BeginProperty Font 
  169.                name            =   "MS Sans Serif"
  170.                charset         =   0
  171.                weight          =   400
  172.                size            =   7.8
  173.                underline       =   0   'False
  174.                italic          =   0   'False
  175.                strikethrough   =   0   'False
  176.             EndProperty
  177.             Height          =   372
  178.             Index           =   1
  179.             Left            =   468
  180.             TabIndex        =   6
  181.             Top             =   720
  182.             Width           =   1212
  183.          End
  184.          Begin VB.CommandButton cmdPlayDate 
  185.             Caption         =   "&Today"
  186.             BeginProperty Font 
  187.                name            =   "MS Sans Serif"
  188.                charset         =   0
  189.                weight          =   400
  190.                size            =   7.8
  191.                underline       =   0   'False
  192.                italic          =   0   'False
  193.                strikethrough   =   0   'False
  194.             EndProperty
  195.             Height          =   372
  196.             Index           =   0
  197.             Left            =   468
  198.             TabIndex        =   5
  199.             Top             =   324
  200.             Width           =   1212
  201.          End
  202.       End
  203.    End
  204.    Begin VB.Frame fraTipsAndTricks 
  205.       Caption         =   "Tips and Tricks..."
  206.       Height          =   2712
  207.       Left            =   72
  208.       TabIndex        =   17
  209.       Tag             =   "slide frame"
  210.       Top             =   3708
  211.       Visible         =   0   'False
  212.       Width           =   5412
  213.       Begin VB.TextBox txtTipsAndTricks 
  214.          Height          =   2352
  215.          Left            =   108
  216.          Locked          =   -1  'True
  217.          MultiLine       =   -1  'True
  218.          ScrollBars      =   2  'Vertical
  219.          TabIndex        =   18
  220.          Top             =   252
  221.          Width           =   5172
  222.       End
  223.    End
  224.    Begin VB.Frame fraPlayingFiles 
  225.       Caption         =   "Playing Waves"
  226.       Height          =   2712
  227.       Left            =   72
  228.       TabIndex        =   16
  229.       Tag             =   "slide frame"
  230.       Top             =   72
  231.       Width           =   5412
  232.       Begin VB.Frame fraPlayList 
  233.          Caption         =   "Play List"
  234.          Height          =   1344
  235.          Left            =   180
  236.          TabIndex        =   23
  237.          Top             =   1152
  238.          Width           =   5052
  239.          Begin VB.CommandButton cmdAddRemove 
  240.             Caption         =   "&Remove"
  241.             Enabled         =   0   'False
  242.             BeginProperty Font 
  243.                name            =   "MS Sans Serif"
  244.                charset         =   0
  245.                weight          =   400
  246.                size            =   7.8
  247.                underline       =   0   'False
  248.                italic          =   0   'False
  249.                strikethrough   =   0   'False
  250.             EndProperty
  251.             Height          =   372
  252.             Index           =   1
  253.             Left            =   144
  254.             TabIndex        =   3
  255.             Top             =   756
  256.             Width           =   1212
  257.          End
  258.          Begin VB.ListBox lstPlayList 
  259.             Height          =   1008
  260.             Left            =   1476
  261.             MultiSelect     =   2  'Extended
  262.             TabIndex        =   4
  263.             Top             =   252
  264.             Width           =   3432
  265.          End
  266.          Begin VB.CommandButton cmdAddRemove 
  267.             Caption         =   "&Add..."
  268.             BeginProperty Font 
  269.                name            =   "MS Sans Serif"
  270.                charset         =   0
  271.                weight          =   400
  272.                size            =   7.8
  273.                underline       =   0   'False
  274.                italic          =   0   'False
  275.                strikethrough   =   0   'False
  276.             EndProperty
  277.             Height          =   372
  278.             Index           =   0
  279.             Left            =   144
  280.             TabIndex        =   2
  281.             Top             =   360
  282.             Width           =   1212
  283.          End
  284.       End
  285.       Begin Threed.SSPanel SSPanel1 
  286.          Height          =   588
  287.          Left            =   180
  288.          TabIndex        =   24
  289.          Top             =   432
  290.          Width           =   5052
  291.          _Version        =   65536
  292.          _ExtentX        =   8911
  293.          _ExtentY        =   1037
  294.          _StockProps     =   15
  295.          BorderWidth     =   1
  296.          BevelOuter      =   1
  297.          BevelInner      =   2
  298.          Begin VB.CommandButton cmdPlay 
  299.             Caption         =   "&Play Wave File(s)"
  300.             BeginProperty Font 
  301.                name            =   "MS Sans Serif"
  302.                charset         =   0
  303.                weight          =   400
  304.                size            =   7.8
  305.                underline       =   0   'False
  306.                italic          =   0   'False
  307.                strikethrough   =   0   'False
  308.             EndProperty
  309.             Height          =   372
  310.             Left            =   108
  311.             TabIndex        =   0
  312.             Top             =   108
  313.             Width           =   3624
  314.          End
  315.          Begin VB.CheckBox chkReverse 
  316.             Caption         =   "Re&verse"
  317.             BeginProperty Font 
  318.                name            =   "MS Sans Serif"
  319.                charset         =   0
  320.                weight          =   400
  321.                size            =   7.8
  322.                underline       =   0   'False
  323.                italic          =   0   'False
  324.                strikethrough   =   0   'False
  325.             EndProperty
  326.             Height          =   264
  327.             Left            =   3852
  328.             TabIndex        =   1
  329.             Top             =   180
  330.             Width           =   1128
  331.          End
  332.       End
  333.    End
  334.    Begin VB.CommandButton cmdSlide 
  335.       Appearance      =   0  'Flat
  336.       BackColor       =   &H00D9A8AE&
  337.       Caption         =   "< &Back"
  338.       Enabled         =   0   'False
  339.       BeginProperty Font 
  340.          name            =   "MS Sans Serif"
  341.          charset         =   0
  342.          weight          =   400
  343.          size            =   7.8
  344.          underline       =   0   'False
  345.          italic          =   0   'False
  346.          strikethrough   =   0   'False
  347.       EndProperty
  348.       Height          =   372
  349.       Index           =   0
  350.       Left            =   888
  351.       TabIndex        =   13
  352.       Top             =   2904
  353.       Width           =   1212
  354.    End
  355.    Begin VB.CommandButton cmdSlide 
  356.       Appearance      =   0  'Flat
  357.       BackColor       =   &H00D9A8AE&
  358.       Caption         =   "&Next >"
  359.       Default         =   -1  'True
  360.       BeginProperty Font 
  361.          name            =   "MS Sans Serif"
  362.          charset         =   0
  363.          weight          =   400
  364.          size            =   7.8
  365.          underline       =   0   'False
  366.          italic          =   0   'False
  367.          strikethrough   =   0   'False
  368.       EndProperty
  369.       Height          =   372
  370.       Index           =   1
  371.       Left            =   2088
  372.       TabIndex        =   14
  373.       Top             =   2904
  374.       Width           =   1212
  375.    End
  376.    Begin VB.CommandButton cmdClose 
  377.       Appearance      =   0  'Flat
  378.       BackColor       =   &H00D9A8AE&
  379.       Caption         =   "&Close"
  380.       BeginProperty Font 
  381.          name            =   "MS Sans Serif"
  382.          charset         =   0
  383.          weight          =   400
  384.          size            =   7.8
  385.          underline       =   0   'False
  386.          italic          =   0   'False
  387.          strikethrough   =   0   'False
  388.       EndProperty
  389.       Height          =   372
  390.       Left            =   3384
  391.       TabIndex        =   15
  392.       Top             =   2916
  393.       Width           =   1212
  394.    End
  395.    Begin VB.Timer tmrStatusLine 
  396.       Enabled         =   0   'False
  397.       Left            =   4680
  398.       Top             =   2916
  399.    End
  400.    Begin Threed.SSPanel panStatusLine 
  401.       Height          =   240
  402.       Left            =   72
  403.       TabIndex        =   19
  404.       Top             =   3384
  405.       Width           =   5412
  406.       _Version        =   65536
  407.       _ExtentX        =   9546
  408.       _ExtentY        =   423
  409.       _StockProps     =   15
  410.       Caption         =   "Ready..."
  411.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  412.          name            =   "MS Sans Serif"
  413.          charset         =   0
  414.          weight          =   400
  415.          size            =   7.79
  416.          underline       =   0   'False
  417.          italic          =   0   'False
  418.          strikethrough   =   0   'False
  419.       EndProperty
  420.       BevelOuter      =   1
  421.    End
  422.    Begin MhwaveLib.MhWave MhWaveDemo 
  423.       Height          =   336
  424.       Left            =   108
  425.       TabIndex        =   21
  426.       Top             =   2916
  427.       Width           =   336
  428.       _Version        =   65536
  429.       _ExtentX        =   593
  430.       _ExtentY        =   593
  431.       _StockProps     =   0
  432.       TintColor       =   16711935
  433.       WaveIndex       =   0
  434.       FilenameRead    =   "Mhwave.frx":0442
  435.    End
  436.    Begin MhcommdlLib.MhCommonDialog MhcommdlDemo 
  437.       Height          =   336
  438.       Left            =   504
  439.       TabIndex        =   20
  440.       TabStop         =   0   'False
  441.       Top             =   2916
  442.       Width           =   336
  443.       _Version        =   65536
  444.       _ExtentX        =   593
  445.       _ExtentY        =   593
  446.       _StockProps     =   4
  447.       TintColor       =   16711935
  448.       Filename        =   ""
  449.       DialogTop       =   0
  450.       DialogLeft      =   0
  451.       DialogWidth     =   0
  452.       DialogHeight    =   0
  453.       InitDir         =   ""
  454.       Filter          =   ""
  455.       DefaultExt      =   ""
  456.       DialogTitle     =   ""
  457.       FilterIndex     =   0
  458.       Flags           =   0
  459.       CancelError     =   0   'False
  460.       MaxFileSize     =   256
  461.       Color           =   0
  462.       Max             =   0
  463.       Min             =   0
  464.       Copies          =   0
  465.       FromPage        =   0
  466.       PrinterDefault  =   -1  'True
  467.       ToPage          =   0
  468.       HelpCommand     =   0
  469.       HelpContext     =   0
  470.       HelpFile        =   ""
  471.       HelpKey         =   ""
  472.    End
  473.    Begin VB.Menu mnuFile 
  474.       Caption         =   "&File"
  475.       Begin VB.Menu mnuFileExit 
  476.          Caption         =   "E&xit"
  477.       End
  478.    End
  479.    Begin VB.Menu mnuAbout 
  480.       Caption         =   "&About..."
  481.    End
  482. Attribute VB_Name = "frmMhWaveOCX_Demo"
  483. Attribute VB_Creatable = False
  484. Attribute VB_Exposed = False
  485. Option Explicit ' always
  486. Public AboutBoxShowing As Boolean
  487. Public NumbersFileLoaded As Boolean
  488. Private bMakeComments As Boolean
  489. Private iNumberOfSlides As Byte, iCurrentSlide As Byte
  490. ' This method moves to the demo's next slide if not already on the last slide
  491. Private Sub ShowSlideNext()
  492.     ' if we are not on the last slide then choose the next slide as the current slide
  493.     If iCurrentSlide < iNumberOfSlides Then iCurrentSlide = iCurrentSlide + 1
  494.     ' have the user interface move to this new slide (view)
  495.     SetupFrames (iCurrentSlide)
  496. End Sub
  497. ' This method returns to the demo's previous slide if not already on the first slide
  498. Private Sub ShowSlidePrevious()
  499.     ' if we are not on the first slide then make the previouse slide the current slide
  500.     If iCurrentSlide >= 1 Then iCurrentSlide = iCurrentSlide - 1
  501.     ' have the user interface move to this new slide (view)
  502.     SetupFrames (iCurrentSlide)
  503. End Sub
  504. Public Sub ShowAbout()
  505.     ' show the about box
  506.     Screen.MousePointer = vbHourglass
  507.     Load frmAbout
  508.     frmAbout.Show
  509.     Screen.MousePointer = vbDefault
  510. End Sub
  511. ' This procedure sets the status line text to the text in sMessageText parameter
  512. '   and keeps the text there for the time period specified (in milliseconds) by the
  513. '   vTimePeriod parameter.  This procedure uses the timer on the demo's mDemoFace form to
  514. '   get a callback when the vTimePeriod has elapsed.
  515. '   sMessageText - text to be displayed
  516. '   [vTimePeriod] - time period (in milliseconds) to display the message.  If not specfied a value
  517. '       of 3000 is used.
  518. '   [vOverRide] - when set to True the sMessageText is displayed immediately even if there is a
  519. '       message currently being displayed.  If set to False (or not specified) and there is a message
  520. '       being displayed the new message is placed in a single item queue and displayed when the time
  521. '       period of the previous message has expired.
  522. Private Sub SetStatusLineText(sMessageText As String, Optional vTimePeriod As Variant, Optional vOverRide As Variant)
  523.     Static sQueueText As String, iQueueTimePeriod As Integer, bQueueIsEmpty As Boolean
  524.     Dim oStatusLine As Control, oStatusLineTimer As Timer
  525.     ' set references to controls on the m_DemoFace form
  526.     Set oStatusLine = panStatusLine
  527.     Set oStatusLineTimer = tmrStatusLine
  528.     ' if the calling procedure did not specify a display time (or set it to <.5 seconds) then default the time to 3 seconds
  529.     Select Case True
  530.     Case IsMissing(vTimePeriod), vTimePeriod <= 500
  531.         vTimePeriod = 3000
  532.     End Select
  533.     ' if the calling procedure did not specify an vOverRide value then set vOverRide to False
  534.     If IsMissing(vOverRide) Then vOverRide = False
  535.     With oStatusLineTimer
  536.         ' if this procedure was called by the timer then turn the timer off and check queue.  If it was not called by the timer
  537.         '   then there is a new message to display.
  538.         If sMessageText = "_timer_calling_" Then
  539.             ' If there is nothing in the queue then reset the status line text to "Ready".
  540.             '   Otherwise, display the message which is in the queue
  541.             .Enabled = False ' turn timer off
  542.             If bQueueIsEmpty Then
  543.                 ' reset status line text
  544.                 oStatusLine.Caption = "Ready..."
  545.             Else
  546.                  ' display message which is in the queue
  547.                  oStatusLine.Caption = sQueueText
  548.                 ' setup timer to call this procedure when the iQueueTimePeriod has expired
  549.                 .Interval = iQueueTimePeriod
  550.                 sQueueText = "" ' clear queue text
  551.                 iQueueTimePeriod = 0 ' clear queue time period
  552.                 bQueueIsEmpty = True ' the queue is now empty so let's indicate this fact
  553.                 .Enabled = True
  554.            End If
  555.         Else
  556.             ' if the timer is enabled then there is already a message being displayed so place
  557.             '   this new message in the single item queue.  But, if this is an over-ride then
  558.             '   show the message now
  559.             If .Enabled And Not vOverRide Then
  560.                 sQueueText = sMessageText
  561.                 iQueueTimePeriod = vTimePeriod
  562.                 bQueueIsEmpty = False
  563.             Else
  564.                 ' over-ride the currently displayed message
  565.                 .Enabled = False
  566.                 sQueueText = "" ' clear queue text
  567.                 iQueueTimePeriod = 0 ' clear queue time period
  568.                 bQueueIsEmpty = True ' the queue is now empty so let's indicate this fact
  569.                 oStatusLine.Caption = sMessageText
  570.                 ' setup timer to call this procedure when the vTimePeriod has expired
  571.                 .Interval = vTimePeriod
  572.                 .Enabled = True
  573.             End If
  574.         End If
  575.     End With
  576. End Sub
  577. ' This procedure sets the percent complete status line of the demo's interface
  578. '   form.
  579. '   iProgress - value to set indicate percent complete of operation.
  580. '       If a value of <0 or > 100 is passed the status line is cleared and reset
  581. Private Sub SetStatusBarProgress(iProgress As Byte)
  582.     Dim StatusBar As Control
  583.     ' set reference to status line on form
  584.     Set StatusBar = panStatusLine
  585.     With StatusBar
  586.         Select Case iProgress
  587.         Case 0 To 100
  588.             ' set the status line flood type if not already set
  589.             If .FloodType <> 1 Then .FloodType = 1
  590.             ' set the value of the percent complete
  591.             .FloodPercent = iProgress
  592.         Case Else
  593.             ' value is outside of valid range so reset status line
  594.             .FloodType = 0
  595.             .FloodPercent = 0
  596.         End Select
  597.     End With ' StatusBar
  598. End Sub
  599. Private Sub cmdClose_Click()
  600.     ' unload this form
  601.     Unload Me
  602. End Sub
  603. Private Sub cmdAddRemove_Click(Index As Integer)
  604.     On Error GoTo cmdAddRemove_Click_Error
  605.     Dim sFileToUse As String, sDialogTitle As String
  606.     Dim iFlags As Integer
  607.     Dim sFilter As String
  608.     Dim bInvalidWaveFile As Boolean
  609.     Select Case Index
  610.     Case 0 ' add
  611.         ' load a new wave file and add it to the list
  612.         iFlags = cdlOFNFileMustExist + cdlOFNPathMustExist + cdlOFNHideReadOnly
  613.         sDialogTitle = "Load Wave File"
  614.         sFilter = "Wave Files|*.Wav"
  615.         ' if the dialog was not canceled and the file is not invalid then load the
  616.         '   file and place it into the list
  617.         If ShowFileDialog(sFileToUse, sFilter, sDialogTitle, iFlags) Then
  618.             With lstPlayList
  619.                 .AddItem sFileToUse
  620.                 MhWaveDemo.WaveIndex = .NewIndex
  621.                 .ItemData(.NewIndex) = .NewIndex
  622.                 MhWaveDemo.FilenameRead = sFileToUse
  623.                 If Not bInvalidWaveFile Then
  624.                     ' if there is no file selected then select one
  625.                     If .ListIndex < 0 Then .ListIndex = 0
  626.                     ' if there are 255 files (the max for the WaveIndex property) then disable the 'Add'
  627.                     If .ListCount >= 255 Then cmdAddRemove(0).Enabled = False
  628.                     cmdAddRemove(1).Enabled = True
  629.                 Else
  630.                     ' remove the newly added file
  631.                     .RemoveItem .NewIndex
  632.                 End If
  633.             End With ' lstPlayList
  634.         End If
  635.     Case 1 ' remove
  636.         cmdAddRemove(0).Enabled = True
  637.         With lstPlayList
  638.             If .ListIndex > -1 Then
  639.                 .RemoveItem .ListIndex
  640.                 ' if there are no items to remove then disabled the 'remove' button
  641.                 If .ListCount < 1 Then cmdAddRemove(1).Enabled = False
  642.             End If
  643.         End With ' lstPlayList
  644.     End Select
  645. Exit Sub
  646. cmdAddRemove_Click_Error:
  647. Select Case Err.Number
  648. Case 32003 ' invalid wave file
  649.     MsgBox "This is not a valid wave file."
  650. Case Else
  651.     MsgBox "Error loading the '" & sFileToUse & "' file."
  652. End Select
  653. If Err.Number Then bInvalidWaveFile = True
  654. Resume Next
  655. End Sub
  656. Private Sub cmdPlay_Click()
  657.     Dim iSelectedWaveFile As Byte, iCount As Byte
  658.     With lstPlayList
  659.         If .ListIndex > -1 And .ListCount > 0 Then
  660.             ' play all selected items
  661.             For iCount = 0 To .ListCount - 1
  662.                 If .Selected(iCount) Then
  663.                     ' disable play button and the play list frame.  They get
  664.                     '   re-enabled in the MhWaveDemo_EndWave event
  665.                     cmdPlay.Enabled = False
  666.                     fraPlayList.Enabled = False
  667.                     MhWaveDemo.WaveIndex = .ItemData(iCount)
  668.                     MhWaveDemo.Reverse = (chkReverse.Value = vbChecked)
  669.                     MhWaveDemo.Play = .ItemData(iCount)
  670.                     ' tell the user what file we are playing
  671.                     Call SetStatusLineText("Playing " & .List(iCount) & "...", 65001, True)
  672.                 End If
  673.             Next iCount
  674.         End If
  675.     End With ' lstPlayList
  676.             
  677. End Sub
  678. Private Sub cmdPlayDate_Click(Index As Integer)
  679.     Dim sDateText As String
  680.     If Not NumbersFileLoaded Then Exit Sub
  681.     Select Case Index
  682.     Case 0 ' today
  683.         sDateText = Format$(Now, "mm/dd/yyyy")
  684.     Case 1 ' yesterday
  685.         sDateText = Format$(DateAdd("d", -1, Now), "mm/dd/yyyy")
  686.     End Select
  687.     MhWaveDemo.Date = sDateText
  688. End Sub
  689. Private Sub cmdPlayDollarAmount_Click(Index As Integer)
  690.     If Not NumbersFileLoaded Then Exit Sub
  691.     MhWaveDemo.Dollar = cmdPlayDollarAmount(Index).Caption
  692. End Sub
  693. Private Sub cmdPlayNumber_Click(Index As Integer)
  694.     If Not NumbersFileLoaded Then Exit Sub
  695.     MhWaveDemo.Number = cmdPlayNumber(Index).Caption
  696. End Sub
  697. Private Sub cmdSlide_Click(Index As Integer)
  698.     ' determine the button that the user pressed
  699.     Select Case Index
  700.     Case 0 ' Go Back
  701.        ShowSlidePrevious
  702.     Case 1 ' Go to Next slide
  703.        ShowSlideNext
  704.     End Select
  705. End Sub
  706. Private Sub Form_Activate()
  707.     Static bBeenRun As Boolean
  708.     If Not bBeenRun Then
  709.         cmdAddRemove(0).SetFocus
  710.         bBeenRun = True
  711.     End If
  712.         
  713. End Sub
  714. Private Sub Form_Load()
  715.     Dim iDisplaySlideLeft As Integer, iDisplaySlideTop As Integer
  716.     Dim sFileToUse As String, sDialogTitle As String
  717.     Dim iFlags As Integer
  718.     Dim sFilter As String
  719.     Dim bInvalidWaveFile As Boolean
  720.     ' place all display frames in the same location as the first frame
  721.     iDisplaySlideTop = fraPlayingFiles.Top
  722.     iDisplaySlideLeft = fraPlayingFiles.Left
  723.     Dim TempControl As Control
  724.     For Each TempControl In Me.Controls
  725.         If TypeOf TempControl Is Frame Then
  726.             With TempControl
  727.                 If .Tag = "slide frame" Then ' frames used as slides have their .Tag properties set to "slide frame"
  728.                     .Left = iDisplaySlideLeft
  729.                     .Top = iDisplaySlideTop
  730.                 End If
  731.             End With ' TempControl
  732.         End If
  733.     Next TempControl
  734.     ' center the form to the screen
  735.     Move Abs(Screen.Width - Width) \ 2, Abs(Screen.Height - Height) \ 2
  736.     ' setup the numbers file if found
  737.     bInvalidWaveFile = False
  738.     MhWaveDemo.ReadNumbersFile = "MhWave.MHW" ' should be in system dir
  739.     Select Case bInvalidWaveFile
  740.     Case False
  741.         NumbersFileLoaded = True
  742.     Case True
  743.         ' it was not found so let the user browse for it if they like
  744.         iFlags = cdlOFNFileMustExist + cdlOFNPathMustExist + cdlOFNHideReadOnly
  745.         sDialogTitle = "Load MH Wave File"
  746.         sFilter = "MH Wave File|*.MHW"
  747.         sFileToUse = "MhWave.MHW"
  748.         If MsgBox("The 'MhWave.MHW' file which ships with OLETools was not found.  It is needed for portions of this demo.  This file should be located in your Windows\System directory.  Would you like to browse for it?", vbYesNo) = vbYes Then
  749.             bInvalidWaveFile = False
  750.             If ShowFileDialog(sFileToUse, sFilter, sDialogTitle, iFlags) Then MhWaveDemo.ReadNumbersFile = sFileToUse
  751.             If Not bInvalidWaveFile Then
  752.                 NumbersFileLoaded = True
  753.             Else
  754.                 NumbersFileLoaded = False
  755.             End If
  756.         Else
  757.             NumbersFileLoaded = False
  758.         End If
  759.     End Select
  760.     bMakeComments = True
  761.     ' we use 3 slide (views) for this demo
  762.     iNumberOfSlides = 3
  763.     ' setup first slide
  764.     SetupFrames (1)
  765.     Call ShowSlideNext
  766.     ' greet the user warmly!
  767.     Dim sGreeting As String
  768.     Randomize (Timer)
  769.     Select Case Int(Rnd * 4)
  770.     Case 0
  771.         sGreeting = "Howdi programmer..."
  772.     Case 1
  773.         sGreeting = "Hi there..."
  774.     Case 2
  775.         sGreeting = "It's MhWave Time!"
  776.     Case Else
  777.         sGreeting = "Welcome to the MicroHelp MhWave Demo!"
  778.     End Select
  779.     Call SetStatusLineText(sGreeting, 5001, True)
  780. Exit Sub
  781. Select Case Err.Number
  782. Case 32000 ' file could not be loaded
  783.     bInvalidWaveFile = True
  784. End Select
  785. End Sub
  786. Private Sub Form_Unload(Cancel As Integer)
  787.     End
  788. End Sub
  789. Private Sub lstPlayList_DblClick()
  790.     ' play the item that the user dbl-clicked
  791.     Call cmdPlay_Click
  792. End Sub
  793. Private Sub MhWaveDemo_EndWave()
  794.     ' re-enabled the play button
  795.     cmdPlay.Enabled = True
  796.     fraPlayList.Enabled = True
  797.     If bMakeComments And Not AboutBoxShowing Then
  798.         ' make a comment on the wave file just played
  799.         Dim sComment As String
  800.         Randomize (Timer)
  801.         Select Case Int(Rnd * 9)
  802.         Case 0
  803.             sComment = "Outstanding clarity!"
  804.         Case 1
  805.             sComment = "Who recorded this wave file?"
  806.         Case 2
  807.             sComment = "Now, that was a cool sound..."
  808.         Case 3
  809.             sComment = "Could be a bit clearer.  But, sounds ok."
  810.         Case 4
  811.             sComment = "That sound reminds me of my childhood."
  812.         Case 5
  813.             sComment = "That one did not really move me."
  814.         Case 6
  815.             sComment = "Where did you get these wave files?"
  816.         Case 7
  817.             sComment = "I think I heard a sneeze in the background of that one..."
  818.         Case 8
  819.             sComment = "Funky!"
  820.         Case 9
  821.             sComment = "Can you play that one again, please?"
  822.         End Select
  823.         Call SetStatusLineText(sComment, 3001, True)
  824.     End If
  825. End Sub
  826. Private Sub mnuAbout_Click()
  827.     ' tell user about the demo by calling the parent object's ShowAbout method
  828.    ShowAbout
  829. End Sub
  830. Private Sub mnuFileExit_Click()
  831.     ' unload form
  832.     Unload Me
  833. End Sub
  834. ' This procedure sets up the different views according to the SlideNumber parameter
  835. Public Sub SetupFrames(SlideNumber As Integer)
  836.     On Error GoTo SetupFrames_Error
  837.     Dim oCurrentFrame As Frame
  838.     Dim sMessageText  As String
  839.     ' enabled/disable the appropriate buttons according to our slide number
  840.     Select Case True
  841.     Case SlideNumber <= 1 ' we are at first slide
  842.         ' disable the back button
  843.         cmdSlide(0).Enabled = False
  844.         ' enable the 'next' button
  845.         cmdSlide(1).Enabled = True
  846.         cmdSlide(1).SetFocus
  847.     Case SlideNumber >= iNumberOfSlides ' we are at last slide
  848.         ' disable the next button
  849.         cmdSlide(1).Enabled = False
  850.         ' enable the 'back' button
  851.         cmdSlide(0).Enabled = True
  852.         cmdSlide(0).SetFocus
  853.     Case Else
  854.         ' enable both buttons
  855.         cmdSlide(0).Enabled = True ' back
  856.         cmdSlide(1).Enabled = True ' next
  857.     End Select
  858.     ' since only one slide uses this text box it can be set to empty to save a little memory
  859.     txtTipsAndTricks.Text = ""
  860.     ' make desired slide visible
  861.     Select Case SlideNumber
  862.     Case 1
  863.         Set oCurrentFrame = fraPlayingFiles
  864.         ' allow program to make comments on the wave file
  865.         bMakeComments = True
  866.         oCurrentFrame.Visible = True
  867.         ' tell user what this slide is about
  868.         sMessageText = "Hit the 'Add' button to load a Wave file!"
  869.         cmdAddRemove(0).SetFocus
  870.     Case 2
  871.         Set oCurrentFrame = fraBuiltInWaves
  872.         oCurrentFrame.Visible = True
  873.         ' do not allow program to make comments on the number files
  874.         bMakeComments = False
  875.         ' tell user what this slide is about
  876.         sMessageText = "Now this is neat!"
  877.     Case 3
  878.         Set oCurrentFrame = fraTipsAndTricks
  879.         oCurrentFrame.Visible = True
  880.         With txtTipsAndTricks
  881.             .Text = "Using The .Reverse Property" & vbCrLf & "The .Reverse property must be set individually for each .Wave file to be played.  Please see the code in the cmdPlay_Click event."
  882.             .Text = .Text & vbCrLf & vbCrLf & "Making Waves" & vbCrLf & "The wave files stored in the MhWave.MHW file can be 'exported' using the WriteNumbersFile property.  Please see the helpfile for more information."
  883.         End With ' txtTipsAndTricks
  884.         ' give user a tip
  885.         sMessageText = "Best advice:  Know your tools, read the manual well!"
  886.         cmdSlide(0).SetFocus
  887.     End Select
  888.     ' make all frames invisible (except for the current frame)
  889.     Dim TempControl As Control
  890.     For Each TempControl In Me.Controls
  891.         If TypeOf TempControl Is Frame Then
  892.             With TempControl
  893.                 If .Tag = "slide frame" And .hWnd <> oCurrentFrame.hWnd Then .Visible = False
  894.             End With ' TempControl
  895.         End If
  896.     Next TempControl
  897.     ' show user message which goes with the selected slide
  898.     Call SetStatusLineText(sMessageText, vOverRide:=True)
  899. Exit Sub
  900. SetupFrames_Error:
  901. Select Case Err
  902. Case 5  ' setfocus while form still not loaded is ok to do
  903. End Select
  904. Resume Next
  905. End Sub
  906. Private Sub tmrStatusLine_Timer()
  907.     ' tell status line that it is time to reset itself
  908.     Call SetStatusLineText("_timer_calling_")
  909. End Sub
  910. Public Function ShowFileDialog(sFileToUse As String, Optional vFilter As Variant, Optional vDialogTitle As Variant, _
  911.                                                     Optional vFlags As Variant) As Boolean
  912. On Error GoTo ShowSaveFileDialog_Error
  913.     ' used to remember the last type of filter the user selected
  914.     Static il_SelectedFilterIndex As Byte
  915.     Dim bDialogCanceled As Boolean
  916.     bDialogCanceled = False
  917.     With MhcommdlDemo
  918.         ' do this so that we can tell if the user hit the cancel button (error cdlCancel is raised)
  919.         .CancelError = True
  920.         ' set the types of files which will appear in the 'filter' combo box
  921.         .Filter = vFilter
  922.         ' if the calling routine passed a filename then make it the default
  923.         If sFileToUse <> "" Then .filename = sFileToUse
  924.         ' select the type of 'filter' that the user used last time, if this is the first time then just select the first filter
  925.         If il_SelectedFilterIndex <> 0 Then
  926.             .FilterIndex = il_SelectedFilterIndex
  927.         Else
  928.             .FilterIndex = 1
  929.         End If
  930.         
  931.         ' set the title if the calling procedure specified one otherwise set a default one
  932.         If Not IsMissing(vDialogTitle) Then
  933.             .DialogTitle = vDialogTitle
  934.         Else
  935.             .DialogTitle = "Open"
  936.         End If
  937.         ' set the .Flags property if the calling procedure set the vFlags parameter
  938.         If Not IsMissing(vFlags) Then .Flags = vFlags
  939.         ' show 'open file' dialog
  940.         .Action = 1
  941.         
  942.         ' remember last filter type used
  943.         il_SelectedFilterIndex = .FilterIndex
  944.         
  945.         ' get the file name from the dialog
  946.         sFileToUse = Trim$(.filename)
  947.         ' return opposite of cancel status
  948.         ShowFileDialog = Not bDialogCanceled
  949.     End With ' MhcommdlDemo
  950. Exit Function
  951. ShowSaveFileDialog_Error:
  952. Select Case Err.Number
  953. Case cdlCancel ' the user hit the cancel button in the 'open file' dialog
  954.     bDialogCanceled = True
  955. End Select
  956. Resume Next
  957. End Function
  958.