Automating Visual C++ IDE using Add-ins and Macros Ranga Narasimhan Microsoft Developer Support Microsoft Corporation - PowerPoint PPT Presentation

ostinmannual
slide1 l.
Skip this Video
Loading SlideShow in 5 Seconds..
Automating Visual C++ IDE using Add-ins and Macros Ranga Narasimhan Microsoft Developer Support Microsoft Corporation PowerPoint Presentation
Download Presentation
Automating Visual C++ IDE using Add-ins and Macros Ranga Narasimhan Microsoft Developer Support Microsoft Corporation

play fullscreen
1 / 21
Download Presentation
Automating Visual C++ IDE using Add-ins and Macros Ranga Narasimhan Microsoft Developer Support Microsoft Corporation
1100 Views
Download Presentation

Automating Visual C++ IDE using Add-ins and Macros Ranga Narasimhan Microsoft Developer Support Microsoft Corporation

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Automating Visual C++ IDE using Add-ins and MacrosRanga NarasimhanMicrosoft Developer SupportMicrosoft Corporation

  2. Scope of the Presentation • Brief introduction to automation • Overview of Microsoft® VC++ ® IDE automation • Various methods of automating VC++ IDE • Overview of add-ins and macros • Debugging add-ins and macros • Customizing the VC++ IDE

  3. Overview: Automation • Automation is based on COM • Automation makes it possible for one application to manipulate objects implemented in another application, or to "expose" objects so they can be manipulated • Automation can be performed by a program written using COM-aware language, for example, VC++, Microsoft® Visual Basic® (VB), and so on

  4. Overview: VC++ Automation • VC++ is an automation server • VC++ automation can be used to extend the capabilities of VC++ • You can automate VC++ using any language that supports COM. Developers normally use VBScript, VC++, and VB

  5. VC++ Automation History • Automation was first introduced with VC++ 5.0 IDE • VC++ 6.0 fixed some major bugs and introduced some new methods (BuildProject.AddFile) • VC++ 6.0 also introduced the “Quick Macro” feature • See “Microsoft Visual C++ 6.0 Migration Guide” topic on MSDN for more information on the new VC++ 6.0 features

  6. VC++ Object Model

  7. Object Model Overview • Provides 17 objects • Objects provide methods and properties • The Application and Debugger objects provide events

  8. VC++ Automation Support • VBScript macro • Add-ins (DLL) written using VC++, VB, or any other language that supports COM • Automation clients (EXE or DLL) written using VC++, VB, or any other language that supports COM • Remote automation through DCOM

  9. Add-ins Macros • Written in VC++, VB, and so on • Can access local computer resources besides object model • Access Win32® API • Early bound • Can control another EXE • Written in VBScript • Can access the object model and some other COM objects • Cannot access Win32 API • Late bound • Cannot control another EXE

  10. Creating a Macro File • In VC++ IDE, on the File menu, click New. • Click the Files tab. • Select “Macro File” and give it a name. • This will create an empty macro (DSM) file where you can start typing code: Sub Test() MsgBox “Hello World” End Sub

  11. Recording a Macro • Another method of creating a macro is by recording. • On the Tools menu, click Macro, and then click Record. • You will have to give it a macro name (description is optional). • The recording starts immediately and the actions that you perform are recorded. • On the Tools menu, click “Stop Recording” to stop recording the macro.

  12. Creating Add-ins • To create a VC++ add-in use the “DevStudio Add-in Wizard.” You have an option to include toolbars and event handling in Step 1 of 1. • To create a VB add-in, use the VB 5.0 add-in sample shipped with the MSDN Library. • You can definitely write an add-in using a language that supports COM.

  13. How Are Add-ins Implemented ? • Implement the IDSAddin interface. This will connect and disconnect the add-in with VC++ • Implement an ICommand interface that DevStudio will use to call your add-in methods • Provide implementation for IApplicationEvents and IDebuggerEvents for event handling (optional) • You are not limited to VC++ and VB for add-in implementation

  14. Installing Add-ins and Macros • On the Tools menu, click Customize. • Click the “Add-ins and Macro files” tab. • Click the Browse button and locate the DSM (Macro) or DLL (Add-in) file. • If it is installed properly, you’ll see a check mark against the macro/add-in. • Click the Close button.

  15. Calling Add-in and Macro Commands • If you have one or more command buttons associated with your macro and/or add-in commands, click those buttons. • You can also start them from the command line: Msdev.exe -ex command name • Call them from another add-in and/or macro using the Application.ExecuteCommand method

  16. Debugging • To debug macros, you should use the PrintToOutputWindow or MsgBox method • To debug add-ins, you will have to specify Msdev.exe as the executable for the debug session because it’s a DLL

  17. Customizing the VC++ IDE • On the Tools menu, click Customize. • Click the Commands tab. • Under Category, click Add-ins or Macros. • Drag the icon listed in the Buttons group to the location you want.

  18. Some Limitations and Known Problems • Macro names cannot have an underscore. It is reserved for event procedures. • You cannot pass arguments to add-in and macro commands. • You cannot start multiple add-in and macro commands. • You can add a project, but cannot remove a project. • You cannot change the output filename for static library project.

  19. Useful Articles • Q247035 “HOWTO: Automate Visual C++” • Q231636 “HOWTO: Controlling the Visual C++ IDE Source Code Editor Window” • Q237870 “HOWTO: Increment Version Information After Each Build in VC++” • Q248130 “FILE: AutoSave.exe Provides AutoSave for Visual C++”

  20. References • “Extend Developer Studio 97 with Your Own Add-ins, Macros, and Wizards,” Steve Zimmerman (MSJ, 9/97) • “Extending Developer Studio with Add-ins,” Richard Grimes (MSDN Library) • Automated Builds in DevStudio, or the Night Build Scenario • “Enhancing the Visual C++ 5.0 Workplace with VBScript Macros” by Mark Davis • “VBScript Language Reference” topic in the MSDN Library