Click here to Skip to main content
15,893,594 members
Articles / Programming Languages / Visual Basic

Filter build output and add sound

Rate me:
Please Sign up or sign in to vote.
3.00/5 (6 votes)
22 Jul 2002CPOL1 min read 51.8K   20   5
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)

Annoyance

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.

Solution

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

Here is the macro:

VB
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 _ 
         BuildEvents.OnBuildDone 
  
         ' Create a tool window handle for the Output window. 
         Dim win As Window = 
           DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput) 
         ' 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) 
         OWp.TextDocument.Selection.SelectAll() 
         Dim Context As String = OWp.TextDocument.Selection.Text 
         OWp.TextDocument.Selection.CharLeft() 
  
         Loc = InStr(Context, "---------- Done -----------") 
  
         OWp = OW.OutputWindowPanes.Item(2) 
         OWp.Activate() 
         OWp.Clear() 
         OWp.OutputString(Mid(Context, 1, Loc - 7)) 
         OWp.TextDocument.Selection.GotoLine_
                 (OWp.TextDocument.EndPoint().Line()) 
  
         '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
         Else 
             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.

License

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


Written By
Web Developer
Israel Israel
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Questionplease you will help me about how can made marks sheet project in vb.net or c#.net? Pin
mohammedali200630-Sep-07 10:21
mohammedali200630-Sep-07 10:21 
GeneralThis feature already exist Pin
AnanthuRaghu30-Mar-05 20:51
AnanthuRaghu30-Mar-05 20:51 
GeneralRe: This feature already exist Pin
citykid6-Jan-06 14:31
citykid6-Jan-06 14:31 
GeneralAdded Build summary for Multiple projects Pin
Rooc29-Apr-04 2:00
Rooc29-Apr-04 2:00 
GeneralCreate handles to the Output window and its panes using C++ Pin
Sheshadri Iyengar11-Mar-03 0:28
Sheshadri Iyengar11-Mar-03 0: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.