Announcement

Collapse
1 of 2 < >

New Sub-Forum

In an effort to help make sure there are appropriate categories for topics of discussion that are happening, there is now a sub-forum for databases and database programming under Special Interest groups. Please direct questions, etc., about this topic to that sub-forum moving forward. Thank you.
2 of 2 < >

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

My solution on removing Beep while using Msgbox

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

  • My solution on removing Beep while using Msgbox

    I hate it where the msgbox statement beeps!
    I hate it, i hate it, i hate it, i hate it, i hate it, i hate it.

    My solution is to negate the sound of the "default beep" in windows and create a function to make my own beeps.

    I personally do not like my programs making annoying beeps. Am i telling my age yet. Beeps were ok in the very beginning but that faded fast.

    I had to learn how to play a wave(.wav) file, i guess i am learning something.
    I thought you would never see me putting sound in a program.
    But never say never, while inserting input for a adding machine where some people rely on sound as feedback from the calculator, i feel sound could be useful in a adding machine program.




    Code:
    'compiler used pbwin 8.04
    'beeptest.bas
    '
    #COMPILE EXE "beeptest.exe"
    '#dim all
    #INCLUDE "win32api.inc"
    
    'the beep sound in msgbox should be an option not a mandatory announce for using the msgbox command.
    'that is the way microsoft wrote the msgbox utility built into windows.
    'until somebody finds a better way to get around the beeping sounds while using msgbox here is my solution
    '
    '
    'by changing the default beep in windows to "none" by accessing the sound feature found inside the control panel.
    '
    'you can get rid of those annoying beeping sounds produced by the msgbox command that absolutely drives me nuts.
    '
    'if you still want to get receive the beep sound msgbox produces, use one of the parameters(styles) below with msgbox
    'MB_ICONERROR  %MB_ICONINFORMATION %MB_ICONQUESTION  %MB_ICONWARNING
    'you will experience a lesser annoying volume of the beep sound than that you would otherwise hear will using these pararmeters(styles).
    
    
    DECLARE FUNCTION BEEPIT(BYVAL numberofbeeps AS LONG, BYVAL beeptimeinterval AS LONG) AS STRING
    
    FUNCTION BEEPIT(BYVAL numberofbeeps AS LONG, BYVAL beeptimeinterval AS LONG)  AS STRING
          WHILE numberofbeeps
          CALL PlaySound("ding.wav", BYVAL NULL%, %SND_ASYNC)
          DECR numberofbeeps
          SLEEP beeptimeinterval
          WEND
    
          'the below command with a file that does exist will produce the sound in the wave file
          'CALL PlaySound("ding.wav", BYVAL NULL%, %SND_ASYNC)
          'CALL PlaySound("buzzingbee.wav", BYVAL NULL%, %SND_ASYNC)
    
          'the below command with a file that does not exist will produce a short beep
          'CALL PlaySound("nofile.wav", BYVAL NULL%, %SND_ASYNC)
    
          'the below command with no file name will produce no sound at all
          'CALL PlaySound("", BYVAL NULL%, %SND_ASYNC)
    
          'the below command will produce a continued sound if the file exist otherwise a short beep
          'the below command with a file that does not exist will produce a short beep"
          'PlaySound "dDDDing.wav", 0, %snd_FileName OR %Snd_LOOP OR %snd_async
    
          'the below command will produce a continued sound if the file exist otherwise a short beep
          'PlaySound "ding.wav", 0, %snd_FileName OR %Snd_LOOP OR %snd_async
    
    END FUNCTION
    
    FUNCTION PBMAIN () AS LONG
    
        'BEEPIT(1,0)    'one beep and no pause after beep
        'BEEPIT(1,1000)  'one beep with a one second pause after beep
      BEEPIT(20,100) '20 beeps 1/10th of a second apart
        'BEEPIT(1,5000)  'one beep and a 5 second pause after beep
    
      sleep 5000  
      MSGBOX ("You should of heard a standard beep using the ding.wav file 20 times fast followed by 5 seconds of silence."+$CRLF+_
              "If the ding.wav file did not exist, you should of have heard of some kind of beeping sound."+$CRLF+_
              "If you have changed the default beep sound used by windows to something other than ding.wav"+$CRLF+_
              "then that's what you should have heard when this message was displayed using the msgbox command.")
    
    END FUNCTION
    Last edited by Paul Purvis; 9 Dec 2007, 05:20 PM.
    p purvis

  • #2
    I hate it where the msgbox statement beeps!
    I hate it, i hate it, i hate it, i hate it, i hate it, i hate it.
    So, why don't you just turn it off? Start -> Settings -> Control Panel -> Sound and Multimedia. Set "Scheme" to "No sound" and you're done. THis is easy for your computer.

    As for other user's computer where applications from you might run: Implementing your code there circumvents a system setting, which I consider to be bad practice.

    Comment


    • #3
      well, more or less this is what i was leading too.
      by editing the default beep to nothing(none) also the BEEP function will not provide a beep work in a windows program.
      i would think microsoft has included a ding.wav file in every os , since many years ago. Therefore one should be able to deduce you can place the above code to provide a beep in programs even where the default beep is removed.
      Even when the above code beepit(1,0) is run just prior to a msgbox, the two beeps will sound more like one because they are so close together. Then you can go ahead and turn off the default beep sounds.


      there was just some new source code listed on another type of msgbox by Dave Biggs and also there is listed code by Charles Dietz at http://www.cgdsoftware.com/

      paul
      p purvis

      Comment

      Working...
      X