Microsoft KB Archive/231636

= How to control the Visual C++ IDE source code editor window size by using the macro file =

Article ID: 231636

Article Last Modified on 4/28/2005

-

APPLIES TO


 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q231636



SUMMARY
In the Visual C++ Integrated Development Environment (IDE) you can open a file belonging to a Project via the Open item on the File menu or from the FileView tab in the Workspace window. You can open files that don't belong to the current project using the File menu's Open item only. The window displaying the file contents opens up docked or with certain dimensions that cannot be specified by anyone.

This article explains how to control the dimensions of the window that is launched when an existing file is opened in the Visual C++ editor.



MORE INFORMATION
The dimensions of the windows containing the file data can be controlled using Visual C++ Automation. The Visual Basic Scripting Edition code below captures the DocumentOpen event and then specifies the Window dimensions: sub Application_DocumentOpen(theDocument) theDocument.ActiveWindow.Height = 500 theDocument.ActiveWindow.Width = 500 end sub Use the following steps to use the above macro in Visual C++:  Open an existing file with the .dsm extension or create one. Paste the above code in the file. In Visual C++ do the following:  From the Tools menu, select Customize. Select the Add-ins and Macros Files tab Click the Browse button to load the DSM file containing the above Macro. Once the file has been selected in the Browse dialog box, your DSM file will appear in the Add-ins and macro file list with a checked box next to it. Click Close to continue.</li></ol> </li></ol>

If you modify the macro, you should reload it by right-clicking within the Visual C++ editor window that has the corresponding .dsm file open and selecting the Reload Macro File item from the shortcut menu.

This macro works for the text-based files only, For example, it has no effect in the Resource Editor. You can also implement this as an Add-In written in Visual C++ or Visual Basic. It handles only opening existing files. To handle creation of new documents, you should use the NewDocument event.

<div class="references_section">