Home > Visual studio > The power of developer studio objects!

The power of developer studio objects!

Here is a nice article by me on this topic, I know these days VC6 is not used by many except for guys like me who like this IDE, buy anyway if you are like me you will like this article…

http://www.codeproject.com/KB/macros/projectsettings.aspx

There are some cool events related to builds provided by visual studio environment, two of them are as follows…

  1. Application_BeforeBuildStart()
  2. Application_BuildFinish()

I use this for switching active projects back and forth, so I’ve got an “All” project which has dependencies set on all projects that I am working on which means I get an “All” compile. I’ve got another project which is my startup project which is not dependent on some of my projects.

Before this macro I had strange bugs because of not building the “Entire” project dues to some changes made to non-dependent projects. For eg: adding a virtual function and this function not getting called!

So what I do with these macros is to switch between these two projects. I switch to “All” before the build starts. Note that I’ve hard coded the project name as “All”…

Set Proj = Nothing
Sub Application_BeforeBuildStart()
On Error Resume Next
    Set Proj = Application.ActiveProject
    Set Application.ActiveProject = Application.Projects("All")
End Sub

And I switch back to my previous “active project” after the build finishes, and this also shows a message box which displays total number of warnings and errors during a build.

Sub Application_BuildFinish( nNumErrors, nNumWarnings )
On Error Resume Next
     If nNumErrors <> 0 Or nNumWarnings <> 0 Then
          MsgBox "You have " & nNumErrors & " errors and " & nNumWarnings & " warnings"
     End If
Set Application.ActiveProject = Proj
End sub

This saves me time. I am sure new IDE’s that has come up will also have similar stuff.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: