Click here to Skip to main content
13,253,863 members (65,841 online)
Click here to Skip to main content
Add your own
alternative version


20 bookmarked
Posted 22 Jul 2002

Filter build output and add sound

, 22 Jul 2002
Rate this:
Please Sign up or sign in to vote.
As I started with VS.NET I had unfamiliarities. The build output had useless stuff and I couldn't make build sounds as I always had. I made the macro to fix it. See and learn (the macro is only for VS.NET)


Changing an IDE can be a difficult thing. All the useful tools you got used to suddenly don't work quite right. Upon starting with VS.NET I had two annoyances:

  1. In VC++ 6 I had nice sounds schemes, a sound for a "error in compile", "warning in compile" (no errors) and "compile succeeded" (no errors and no warnings). Sadly, in VC.NET the sounds system is kinda messed up - I couldn't set sound on warning and also it insisted playing some general sounds from the control panel (something that pissed me off).
  2. VS.NET generates in the build output some lines in the end that I don't need:
    ---------------------- Done ----------------------
         Build: 1 succeeded, 0 failed, 0 skipped

    And it scrolls up too much so I don't see the much more important - number of errors/warnings. This together with problem #1 can be annoying.

These problems are no way critical, but I want to feel comfortable and I prefer squashing annoyances to living with them.


To install the macro put it in your macro file under EnviromentEvents() function.

Here is the macro:

Declare Function sndPlaySound Lib "winmm.dll" _ 
    Alias "sndPlaySoundA" (ByVal lpszSoundName As String, _ 
    ByVal uFlags As Long) As Long 
     Public Declare Function waveOutGetNumDevs Lib "winmm" () As Long 
     'just after the sound is ended Exit Function 
     Const SND_SYNC = &H0 
     'just after the beginning of the sound Exit Function 
     Const SND_ASYNC = &H1 
     'if the sound cannot be found no Error message 
     Const SND_NODEFAULT = &H2 
     'repeat the sound until the Function is called again 
     Const SND_LOOP = &H8 
     'if currently a sound is played the 
     'Function will return without playing the selected sound 
     Const SND_NOSTOP = &H10 
     Const Flags& = SND_ASYNC Or SND_NODEFAULT 
     Public Sub BuildEvents_OnBuildDone(ByVal _
         Scope As EnvDTE.vsBuildScope, _ 
         ByVal Action As EnvDTE.vsBuildAction) Handles _ 
         ' Create a tool window handle for the Output window. 
         Dim win As Window = 
         ' Create handles to the Output window and its panes. 
         Dim OW As OutputWindow = win.Object 
         Dim OWp As OutputWindowPane 
         Dim Loc As Integer 
         OWp = OW.OutputWindowPanes.Item(1) 
         Dim Context As String = OWp.TextDocument.Selection.Text 
         Loc = InStr(Context, "---------- Done -----------") 
         OWp = OW.OutputWindowPanes.Item(2) 
         OWp.OutputString(Mid(Context, 1, Loc - 7)) 
         'Play sounds 
         If InStr(Context, "0 error(s)") = 0 Then 
             sndPlaySound("Error.wav", SND_SYNC) ' Edit
         ElseIf InStr(Context, "0 warning(s)") = 0 Then 
             sndPlaySound("Warning.wav", SND_SYNC) ' Edit
             sndPlaySound("Fine.wav", SND_SYNC) ' Edit
         End If 
     End Sub

Don't forget to edit the wav file names to suit it to your needs. After that go back to your project and work as usual.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Vitaly Belman
Web Developer
Israel Israel
No Biography provided

You may also be interested in...


Comments and Discussions

Questionplease you will help me about how can made marks sheet project in or Pin
mohammedali200630-Sep-07 11:21
membermohammedali200630-Sep-07 11:21 
GeneralThis feature already exist Pin
AnanthuRaghu30-Mar-05 21:51
memberAnanthuRaghu30-Mar-05 21:51 
GeneralRe: This feature already exist Pin
citykid6-Jan-06 15:31
membercitykid6-Jan-06 15:31 
GeneralAdded Build summary for Multiple projects Pin
Rooc29-Apr-04 3:00
memberRooc29-Apr-04 3:00 
GeneralCreate handles to the Output window and its panes using C++ Pin
Sheshadri Iyengar11-Mar-03 1:28
memberSheshadri Iyengar11-Mar-03 1:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171114.1 | Last Updated 23 Jul 2002
Article Copyright 2002 by Vitaly Belman
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid