INFO: Visual Studio Macros for MFC and ATL Source Code (201177)



The information in this article applies to:

  • The Microsoft Active Template Library (ATL) 3.0
  • The Microsoft Foundation Classes (MFC), when used with:
    • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 5.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0
  • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
  • Microsoft Visual C++, 32-bit Professional Edition 6.0
  • Microsoft Visual C++, 32-bit Learning Edition 6.0

This article was previously published under Q201177

SUMMARY

Opening an SDK or Visual C++ header, or source file can be a tedious task as it often requires typing the full Visual C++ installation path (C:\Program Files\Microsoft Visual Studio\VC98) followed by the directory that you are interested in (include, atl\include, mfc\src, and so forth).

MORE INFORMATION

The Visual Studio macros included in this article reduce this typing to a keystroke sequence or button press. These macros open a File Open dialog box with the directory set appropriately. For example, running the macro ATLInclude below invokes the File Open command with the directory set to the ATL Include directory.

These macros are handy when attached to a tool bar button in the Visual C++ Integrated Development Environment (IDE).
'---------------------------------------------------------------------
' FILE DESCRIPTION: Macros for opening MFC/ATL Source files.
' - Change the BaseDir settings for your installation
'----------------------------------------------------------------------
BaseDir ="C:\Program Files\Microsoft Visual Studio\VC98\"

Sub Include
   'DESCRIPTION: Open VC Include dir
   OpenDir "include"
End Sub

Sub ATLInclude
   'DESCRIPTION: Open ATL Include dir
   OpenDir "ATL\include"
End Sub

Sub ATLSrc
   'DESCRIPTION: Open ATL Source dir
   OpenDir "ATL\src"
End Sub

Sub MFCInclude
   'DESCRIPTION: Open MFC Include dir
   OpenDir "MFC\include"
End Sub

Sub MFCLib
   'DESCRIPTION: Open MFC Library dir
   OpenDir "MFC\lib"
End Sub

Sub MFCSrc
   'DESCRIPTION: Open MFC Source dir
   OpenDir "MFC\src"
End Sub

Private Sub OpenDir(dir)
   OriginalDir = CurrentDirectory
   CurrentDirectory = BaseDir + dir
   ExecuteCommand "FileOpen"
   CurrentDirectory = OriginalDir
End Sub
				
Follow these steps to create a toolbar item out of one of these macros:
  1. From the Tools menu in the IDE, click Customize.
  2. On the Commands tab, select Macros from the Category drop-down list box.
  3. Drag-and-drop the macro from the Commands list onto an existing toolbar or into blank space in the IDE.
  4. Select an image from the pop-up Button Appearance dialog box and click OK.

REFERENCES

Visual Studio Macro Reference

Modification Type:MajorLast Reviewed:12/2/2003
Keywords:kbAutomation kbDevStudio kbide kbinfo kbScript KB201177