Slide1 l.jpg
Advertisement
This presentation is the property of its rightful owner.
1 / 21

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

Automating Visual C++ IDE using Add-ins and Macros Ranga Narasimhan Microsoft Developer Support Microsoft Corporation Scope of the Presentation Brief introduction to automation Overview of Microsoft ® VC++ ® IDE automation Various methods of automating VC++ IDE

Download Presentation

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

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Slide1 l.jpg

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


Scope of the presentation l.jpg

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


Overview automation l.jpg

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


Overview vc automation l.jpg

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


Vc automation history l.jpg

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


Vc object model l.jpg

VC++ Object Model


Object model overview l.jpg

Object Model Overview

  • Provides 17 objects

  • Objects provide methods and properties

  • The Application and Debugger objects provide events


Vc automation support l.jpg

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


Add ins macros l.jpg

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


Creating a macro file l.jpg

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


Recording a macro l.jpg

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.


Creating add ins l.jpg

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.


How are add ins implemented l.jpg

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


Installing add ins and macros l.jpg

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.


Calling add in and macro commands l.jpg

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


Debugging l.jpg

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


Customizing the vc ide l.jpg

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.


Some limitations and known problems l.jpg

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.


Useful articles l.jpg

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++”


References l.jpg

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


  • Login