Gold mine of Visual C++ tricks!
Let Visual Studio talk to you – Events in Visual Studio Object Model.
![]()
Did you ever wish to see a “Bye Bye!” from Visual Studio when you exit? Did you ever wish to see a message, when the build is completed, instead of that boring chime sound? The answer is – Visual Studio Object Model Events.
![]()
Visual Studio Object model Events are the ones, which Visual Studio triggers on specified events. They can be easly accessed by writing simple VBScript macros. See the following step by step instructions.
1) Start Visual Studio.
2) Take Tools -> Macro
3) Click Options -> New File and save a new macro file by specifying a name such as “VSEvents” or something like that.
4) Click Edit button and give macroname as “HelloWorld” or something like that.
5) Now you can see a VBScript editor window for editing macros. Actually we’ve added “HelloWorld” for just starting the editor. If there are no macro inside a file, it cannot be edited.
6) Now in the editor add the following lines to the bottom
Sub Application_BeforeApplicationShutDown ' Say ByeBye to master when he leaves! MsgBox "Bye Bye!" End Sub sub Application_BuildFinish(nNumErrors, nNumWarnings) ' Build Finished. MsgBox "Master, Wakeup! the build is finished." end sub
7) Save everything and exit Visual Studio.
8 ) Now Start VisualStudio and try to exit. The Visual studio says “Bye Bye!”.
9) Try to compile a project, Visual Studio will shows a message when compilation is finished!
There is a couple of other events too. They are,
Application_BeforeApplicationShutDown Application_BeforeBuildStart Application_BeforeDocumentClose Debugger_BreakpointHit Application_DocumentOpen Application_DocumentSave Application_NewDocument Application_WindowActivate Application_WindowDeactivate Application_WorkspaceClose Application_WorkspaceOpen
Have a look at them too. See their description in MSDN.
![]()
Since its intended for beginners, i’ve described step by step. If you are advanced, then just write a .dsm file with these macro as contents and put to <VisualStudioDir>\Common\MSDev98\Macros. Then load that macro file in Visual Studio.
![]()
Targeted Audience – Beginners.
| Print article | This entry was posted by Jijo Raj on April 10, 2008 at 5:51 pm, and is filed under Uncategorized. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |