Article ID: 192913
Article Last Modified on 12/11/2003
Private WithEvents DevSt As DSSharedObjects.Application
Private Sub CheckBuildEvents(strWksp As String)
Dim cfg As DSProjectSystem.Configuration
' Create a new instance of DevStudio.
Set DevSt = New DSSharedObjects.Application
DevSt.Visible = True ' Developer Studio must be invisible for
' EnableModeless.
DevSt.EnableModeless (False)
Debug.Print "Opening Workspace "; strWksp
DevSt.Documents.Open strWksp
cfg = DevSt.ActiveProject.Configurations.Item(1)
Debug.Print "Starting build: "; cfg
DevSt.RebuildAll cfg
Debug.Print "Closing workspace "; strWksp
DevSt.ExecuteCommand "WorkspaceClose"
DevSt.EnableModeless (True) ' Events occur here if DevStudio is
' visible.
DevSt.Quit
End Sub
Private Sub DevSt_BeforeBuildStart()
Debug.Print ">BeforeBuildStart"
End Sub
Private Sub DevSt_BuildFinish(ByVal nErr As Long, ByVal nWrn As Long)
Debug.Print ">BuildFinish: nErr ="; nErr; "; nWrn ="; nWrn
End Sub
For example, if you have a workspace named MyWksp.dsw with one project
named MyProj, the following Visual Basic subroutine call
CheckBuildEvents "MyWksp.dsw"produces the following output in the debug window:
Opening Workspace MyWksp.dsw Starting build: MyProj - Win32 Release Closing Workspace MyWksp.dsw >BeforeBuildStart >BuildFinish: nErr = 0; nWrn = 0Now modify the subroutine, changing the following line
DevSt.Visible = True ' Developer Studio must be invisible for
' EnableModeless.
to the following:
DevSt.Visible = FalseRerunning the test correctly produces the following output:
Opening Workspace MyWksp.dsw Starting build: MyProj - Win32 Release >BeforeBuildStart >BuildFinish: nErr = 0; nWrn = 0 Closing Workspace MyWksp.dsw
192912 BUG: MSDev Doesn't Close When COM Reference Is Zero
Keywords: kbbug kbvcobj kbautomation kbdevstudio kbprb kbpending KB192913