Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

The Sweet Sounds of XP

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • The Sweet Sounds of XP

    Note it puts the .Wav name in the Clipboard.

    Send remarks to


    '
    Code:
    '               PBWIN 9.00 - WinApi 05/2008 - XP Pro SP3
    'http://www.powerbasic.com/support/pbforums/showthread.php?p=296028#post296028
    '
    #Dim All 
    #Compile Exe  
    #Include "WIN32API.INC"
    '
      Global hdlg As Dword                
      Global Sounds$(), Btn_Id&() 
      Global Dlg_Hght&, Dlg_Wdth&
    '
    Macro Common_Locals 'Macro easier than retyping and maintains coding consistency
      Local ctr&, ln&, ln1&, i&, s$
      Local hght&, wd&, Longest&, l$
      Local Row&, col&
     
    End Macro  
    '
    CallBack Function Dialog_Processor
       Common_Locals
      Select Case CbMsg     'This is TO determine the message TYPE 
         '       
         Case %WM_INITDIALOG'<- Initialiaton when the program loads 
         '
         Case %WM_SYSCOMMAND 'Traps Any Alt key but only F4 closes              
         '
         Case %WM_COMMAND  'This processes command messages
           Select Case CbCtl 'which control is sending msg
             Case Btn_Id(1) To Btn_Id(UBound(Btn_Id))
               Select Case CbCtlMsg 'msg sent   
                  Case %bn_Clicked 'Bingo
                    ctr = CbCtl - 1000 'yields array number
                     If ctr => LBound(Sounds$()) And _ 'check for bounds error JIC
                        ctr =< UBound(Sounds$()) Then
                        s$ = Sounds$(ctr) & ".wav" 'for convenience
                        SndPlaySound s$ & Chr$(0), ByVal 0
                        ClipBoard Set Text s$ To ctr 'put name in clipboard
                     End If
               End Select
           End Select
      End Select
    End Function
    '
    Sub Buttons_Setup 
      common_Locals                   
      '
      Call Sound_Data 'get sounds & Button ids
      'determine Button Width
      For ctr = LBound(Sounds$()) To UBound(Sounds$())
         ln = Len(Sounds$(ctr)) 'how long is it
         If ln > Longest Then Longest = ln
      Next ctr
      '
      Longest = Longest * 6 'pixels per character
      '   
      hght = 20 'btn height
     
      Col = 8 'space on left
      Row = 5 'space at top
      For ctr = LBound(Sounds$()) To UBound(Sounds$())
         Control Add Button, hdlg, Btn_Id(ctr), Sounds$(ctr), Col, Row, Longest, hght 
         Row = Row + hght + 3
         If Row > Dlg_Hght - 20 Then 'at bottom of dialog
            Row = 5 'start at top again
            Col = col + Longest + 10 'Move over Rover
         End If 
      Next ctr
    End Sub
    '
    Function PBMain
      common_Locals 'not needed here but JIC
      '
      Dlg_Hght = 12 * 28 
      Dlg_Wdth = 525
      Dialog New Pixels, hdlg, "The Sweet Sounds of XP", , , Dlg_Wdth, Dlg_Hght, %WS_SYSMENU To hdlg
      '
      Buttons_Setup 'build buttons
      '
         Dialog Show Modal hDlg   Call Dialog_Processor 
    End Function                                
    '
    Sub Sound_Data
      Common_Locals
      ctr = DataCount 'count data items
      Dim Sounds$(1 To ctr), Btn_Id(1 To ctr)'assign arrays
     
      For ctr = 1 To DataCount 'now fill arrays
         S$ = Read$(ctr) 'get sound
         Sounds$(ctr) = Left$(s$, Len(s$) - 4) 'strip off ".wav"
         Btn_Id(ctr) = 1000 + ctr 'assign a button id
      Next ctr
      '
    Data chimes.wav
    Data chord.wav
    Data ding.wav
    Data flourish.mid
    Data Notify.wav
    Data onestop.mid
    Data recycle.wav
    Data ringin.wav
    Data ringout.wav
    Data start.wav
    Data tada.wav
    Data town.mid
    Data Windows Feed Discovered.wav
    Data Windows Information Bar.wav
    Data Windows Navigation Start.wav
    Data Windows Pop-up Blocked.wav
    Data Windows XP Balloon.wav
    Data Windows XP Battery Critical.wav
    Data Windows XP Battery Low.wav
    Data Windows XP Critical Stop.wav
    Data Windows XP Default.wav
    Data Windows XP Ding.wav
    Data Windows XP Error.wav
    Data Windows XP Exclamation.wav
    Data Windows XP Hardware Fail.wav
    Data Windows XP Hardware Insert.wav
    Data Windows XP Hardware Remove.wav
    Data Windows XP Information Bar.wav
    Data Windows XP Logoff Sound.wav
    Data Windows XP Logon Sound.wav
    Data Windows XP Menu Command.wav
    Data Windows XP Minimize.wav
    Data Windows XP Notify.wav
    Data Windows XP Pop-up Blocked.wav
    Data Windows XP Print complete.wav
    Data Windows XP Recycle.wav
    Data Windows XP Restore.wav
    Data Windows XP Ringin.wav
    Data Windows XP Ringout.wav
    Data Windows XP Shutdown.wav
    Data Windows XP Start.wav
    Data Windows XP Startup.wav
    End Sub
    '
    It's a pretty day. I hope you enjoy it.

    Gösta

    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/
Working...
X