Click here to Skip to main content
12,621,744 members (33,568 online)
Click here to Skip to main content
Add your own
alternative version

Stats

46.5K views
20 bookmarked
Posted

Filter build output and add sound

, 22 Jul 2002 CPOL
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)

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:

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)

Share

About the Author

Vitaly Belman
Web Developer
Israel Israel
No Biography provided

You may also be interested in...

Pro
Pro

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 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.

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