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:
- 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).
- 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
Const SND_SYNC = &H0
Const SND_ASYNC = &H1
Const SND_NODEFAULT = &H2
Const SND_LOOP = &H8
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
Dim win As Window =
DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
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())
If InStr(Context, "0 error(s)") = 0 Then
sndPlaySound("Error.wav", SND_SYNC)
ElseIf InStr(Context, "0 warning(s)") = 0 Then
sndPlaySound("Warning.wav", SND_SYNC)
Else
sndPlaySound("Fine.wav", SND_SYNC)
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 member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.