Share via


Events

Home Page (Objects)OverviewFAQReference

An event is an action or occurrence, often generated by the user, to which a VBScript event handler, Developer Studio add-in, or other Automation controller can respond. For example, if a user clicks on a window, Developer Studio fires the WindowActivate event of the Application object.

The following events are available:

Event Description
BeforeApplicationShutDown Occurs before Developer Studio shuts down.
BeforeBuildStart Occurs before a build starts.
BeforeDocumentClose Occurs before a specified document closes.
BreakpointHit Occurs when a breakpoint is hit.
BuildFinish Occurs after a build completes.
DocumentOpen Occurs after a specified document opens.
DocumentSave Occurs after a specified document is saved.
NewDocument Occurs after a specified document is created.
NewWorkspace Occurs after a workspace is created.
WindowActivate Occurs after a specified window becomes active.
WindowDeactivate Occurs after a specified window becomes inactive.
WorkspaceClose Occurs after a workspace closes.
WorkspaceOpen Occurs after a workspace opens.

In a VBScript event handler, you can respond to an event by taking some action. For instance, you could change the size of a window by setting the Height and Width properties of the Window object.

To respond to an event, add the appropriate event handler to any loaded VBScript macro file. You can add this event handler to multiple VBScript macro files. For example, if you add an event handler for the WindowActivate event to two loaded VBScript macro files, when the user activates a window, both of these event handlers will be called — one at a time.

To add the event handler, find the appropriate event by using the previous table, copy the sample event handler from the example, paste the handler into your macro file, insert the appropriate code into the handler, and then reload the macro file.

For example, you could take some action just before Developer Studio quits by using the BeforeApplicationShutDown event. To use this event, go to the description of the event and copy the sample event handler:

sub    Application_BeforeApplicationShutDown()
   ' Insert code to handle the event here
end sub

Then, paste this code into your macro file, insert the code for handling the event, and then reload the macro file.

Tip   To reload the macro file, open the file in the text editor, click the right mouse button, and then click Reload Macros in File.