Using Events with Developer Studio Objects
Home Page (Objects) | Overview | FAQ | Reference
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.
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 in the documentation, 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 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.