Macros, Wizards and Add-ins

There are basically three methods you can use in order to extend the Developer Studio environment. The simplest is to write some macros in an ActiveX Scripting language and make them available via toolbar buttons or menu commands. These macros run inside the DevStudio 97 IDE and can access the objects exposed. In this way, you can modify the active document, navigate the list of the opened windows, run any of the predefined commands and macros, and so on. A large number of macros are already built-in and you just have to know about them to use them.

Most of these macros refer to menu commands. More generally, let's say that most of these predefined macros execute programmatically a significant part of the usually entirely manual tasks To see the complete list, just open the Tools|Customize menu and choose the tab labeled Commands. From the Category combo, select the item All Commands.

To write your own macros, however, you need to open a different dialog. This is found under the Tools|Macro menu.

The picture shows how the dialog will appear once you've written some macros. Otherwise, it will show up blank. To add macros, just click on Edit. Notice that under the button Options >> you're given the possibility of associating your macro with a menu command or a toolbar. The next screenshot shows how it looks.

With macros you can do lots of things, but you are limited to the expressive power of a script language like VBScript. It is pretty easy to use, but sometimes there are tasks that you would accomplish better with more powerful tools.

Add-ins, for example, in-process COM servers—like ActiveX controls—are loaded when the IDE starts up. They can access the object model and modify it too. You can write them in C++, and even in Visual Basic. Since they are actually DLLs, you can create local or temporary files, perform any type of check, display your own dialogs, create windows, connect to other servers, read/write the clipboard or the registry, and so on. In other words, you can exploit the power of a real programming language. Add-ins allow you to automatically respond to the Developer Studio's events. Receiving IDE events, however, is also possible with macros. This lets you hook for the build to start and finish, for the creation of new documents and for all the open/save activity. The environment also offers a wizard to help you to write bare-bones add-ins. To write and understand add-ins, it's recommended that you have a certain familiarity with simple COM programming.

The third way to program the Developer Studio environment is by using wizards. When you choose to create a new project, you're prompted with a dialog like this:

Once you've picked an item, an automatic procedure will guide you through the various steps of the process. The final result is a new opened project, whose files have the features you selected step-by-step. These wizards are mostly oriented to the building of applications. Hence their exact name; AppWizards. If we had an AppWizard for writing scriptlets, then we could allow the user to select options like the name of the pages, the standard events to support, the number and the name of properties and methods, stock properties and so on. However, such a wizard cannot work outside the Developer Studio environment.

© 1997 by Wrox Press. All rights reserved.