Click here to Skip to main content
11,924,825 members (51,446 online)
Click here to Skip to main content
Add your own
alternative version


39 bookmarked

AutoText Add-in for Visual Studio 6.0

, 3 Mar 2001
Rate this:
Please Sign up or sign in to vote.
Adds the auto text feature from MS Word (tm) to the Developer Studio (tm)
<!-- Download Links --> <!-- Article image -->

Sample Image - DeveloperStudioAutoText.gif

<!-- Main HTML starts here -->


I have been using this tool for about a year now for my personal use and it works quite fine. After reading some articles here on CodeProject I felt like I needed to give back something useful to the community. So here it is...

This add-in adds an AutoText feature to Visual Studio similar to the one found in MS Word (tm). It replaces misspellings or can replace abbreviated words while typing with their full text. This can be used to abbreviate hard to type names; for example, UNUSED_ALWAYS (which I abbreviated to ua ). Or to correct common spelling errors; for example, typing TURE and having it replaced with TRUE.

Current version: Version 1,0,0.1 (February 21, 2001)
I'll post updates here when available.


Either download the file and build it for yourself or just download the ready to use build then copy the file DeveloperStudioAutoText.dll to c:\Program Files\microsoft visual studio\common\msdev98\addins or where ever you have installed your copy of visual studio respectively.
  1. Copy DeveloperStudioAutoText.dll to any place you want. A good place would be under the Microsoft Visual Studio folder at Common\MDev98\AddIns.
  2. Open Visual Studio and select: Tools | Customize...
  3. Go to the Add-ins and Macro files tab and click on the Browse button.
  4. Go to the folder to which you copied DeveloperStudioAutoText.dll and select it. Make sure the "files of type" listbox is set to "Add-ins (.dll)".
  5. When closing the dialog, a toolbar will appear with the AutoText-Configuration button (Large 'T' with small "Auto" below it" and a button labeled "H/C+" which toggles between C(++) and the .H-file.
    Like with any other toolbar button you can move this button to any other toolbar.
  6. Press the left button (with the 'T' on it) to setup the AutoText replacement table. Here you can enable/disable the plug-in trough switching on/off the Enable AutoText checkbox.
  7. Type in the Replace edit box the text to be replaced and in the With edit box the text to replace it with. Then press or click on Add New to add it.
  8. With the Delete button you can remove unwanted entries and when the replace text already exists, the Add New button changes to Replace to let you modify existing entries.
  9. When you press the OK button all settings are written to the file %windir%\DSAutoText.CFG which is in fact a standard .INI-file. You may edit it by hand (it's syntax is quite straightforward: In the section [Substitutions] there is a mapping between the original text on the left and the text to replace it with on the right side of the equal sign.
    You should not modify WordListState. This one contains the list view settings (column width and ordering)
  10. While typing the add-in watches for space and opening brackets. When you enter any of these it will search its replacement list and when it finds a suitable one, replaces your typed word with it.
  11. When the replaced text is not what you wanted, just delete it using edit/undo or pressing the backspace key and retype the original text, the next time you enter one of the stopping chars (space or bracket) it will ask if it should replace it and you can cancel replacing by pressing ESC or selecting DON'T REPLACE.
    Replace with question menu

How it works

On loading it tries to identify the main window and the MDIClientArea window (method CDSAddIn::OnConnection). The interesting part follows:
//First find the main window
hWnd = ::GetActiveWindow();
while( hWnd  &&  hWnd != hDesktopWnd )
    m_hDevStudioWnd = hWnd;
    hWnd = ::GetParent(hWnd);

GetWindowText( m_hDevStudioWnd, szWindowTitle, 512 );

if( strstr( szWindowTitle, "Microsoft Visual C++" ) )
   m_wndDevStudioMainWindow.SubclassWindow( m_hDevStudioWnd );

   // The MDIArea always has ID 0xe900
   m_hDevStudioMDIArea = GetDlgItem( m_hDevStudioWnd, 0xe900 );

   m_wndMDIAreaManager.SubclassWindow( m_hDevStudioMDIArea );
The line m_wndDevStudioMainWindow.SubclassWindow( m_hDevStudioWnd ); subclasses the DevStudio main window (class C_DevStudioMainWindowFilter. This is necessary because it would otherwise translate some of the cursor movements to WM_COMMAND messages. But as we need the cursor messages we intercept them.

There is another class C_DevStudioMainWindowFilter that is mainly used to easily get the active MDI (a.k.a. text editor) window and to handle the menu and normal keys.

The decision process, if anything needs to be replaced can be found in C_ActiveMDIWindowFilter::OnSpecialKeyPressed(). Of interest, may be the handling of m_bEnableAutoCorrect, which determines if the entered text is automatically replaced or if the user is asked if it should be replaced (after the user pressed delete it will be set to FALSE and back to TRUE when a stop char is pressed).

The actual replacing occurs in CheckAutoText(). If bAutoReplace is TRUE the text will immediately be replaced if possible. Otherwise only the replacement text (if available) will be returned. If there is nothing typed by the user that can be replaced then the return value will be empty and the text will not be changed.

Known Problems

MsDev6 on some systems has a problem to paste text to the editor (Edit/Paste) when copied from the same text window when using macros/add-ins.
As far as I know it's possible to fix this by disabling the new heap manager by adding the following registry key (at least it works on my colleges systems):
Add this key with regedit:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MSDEV.EXE
then add a string value beneath it named DisableHeapLookaside and set it to "1".

This add-in was built with Visual C++ 6.0 with service pack 4. I have tested it also with service pack 3 and it worked fine there too, so I guess it won't make problems with different service packs.

See Q231652 and Q195009 in the knowledge base for more information.

Version History

Version 1,0,0.1
First public release.


The initial idea of subclassing the main window (but not the technique) was also taken from an addin found on code guru. But after over one year I forgot who it was. Sorry about that.

Some of the copyright notices was taken from Yuri Tkachov's enhanced windowlist submission. I hope he does not mind.

Further I have to thank my company (MicroMotion GmbH) for letting me use their equipment (and some time on working hours) to write this addin. (btw. this addin does not fulfill internal coding standards - it's a hobby project)

About Christoph Weber

Christoph Weber is a member of the core development team at MicroMotion GmbH.
He's programming Assembler/C/C++ (and some more) for 18 years now and Visual C++/MFC and ATL for 6 years.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Christoph Weber
Germany Germany
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionWhat about VC5 ? Pin
Volki28-Jan-02 14:48
memberVolki28-Jan-02 14:48 
AnswerRe: What about VC5 ? Pin
Christoph Weber29-Jan-02 11:32
memberChristoph Weber29-Jan-02 11:32 
GeneralRe: What about VC5 ? Pin
Volkan29-Jan-02 15:04
memberVolkan29-Jan-02 15:04 
GeneralCrash... Pin
| mProject |20-Dec-01 22:51
member| mProject |20-Dec-01 22:51 
GeneralRe: Crash... Pin
Christoph Weber22-Dec-01 4:31
memberChristoph Weber22-Dec-01 4:31 

I guess you are right that it's a problem with subclassing.
There has been an other thread discussing the problems with multiple plugins subclassing and unsubclassing some of the devstudio windows.

Currently there is no real solution and I'm afraid my time available does not permit me to fix it.

The only workaround is to change the load status directly in the registry (see other thread) before devstudio loads.

BTW: Which other addins do you use?

GeneralRe: Crash... Pin
MM5-Feb-02 20:38
memberMM5-Feb-02 20:38 
GeneralProblems with paste Pin
Anonymous6-Mar-01 19:20
memberAnonymous6-Mar-01 19:20 
GeneralRe: Problems with paste Pin
Simon Hughes6-Mar-01 23:58
memberSimon Hughes6-Mar-01 23:58 
GeneralRe: Problems with paste Pin
Christoph Weber7-Mar-01 2:20
memberChristoph Weber7-Mar-01 2:20 
GeneralRe: Problems with paste Pin
Joshua Jensen7-Mar-01 10:37
memberJoshua Jensen7-Mar-01 10:37 
GeneralRe: Problems with paste Pin
Anonymous14-Mar-01 13:07
memberAnonymous14-Mar-01 13:07 
GeneralFunctioning with other add-ins Pin
Ray Hayes6-Mar-01 1:00
memberRay Hayes6-Mar-01 1:00 
GeneralRe: Functioning with other add-ins Pin
Simon Capewell6-Mar-01 4:27
memberSimon Capewell6-Mar-01 4:27 
GeneralRe: Functioning with other add-ins Pin
Christoph Weber6-Mar-01 11:03
memberChristoph Weber6-Mar-01 11:03 
GeneralRe: Functioning with other add-ins Pin
Simon Capewell7-Mar-01 0:18
memberSimon Capewell7-Mar-01 0:18 
GeneralRe: Functioning with other add-ins Pin
Christoph Weber7-Mar-01 4:42
memberChristoph Weber7-Mar-01 4:42 
GeneralRe: Functioning with other add-ins Pin
Joshua Jensen7-Mar-01 10:40
memberJoshua Jensen7-Mar-01 10:40 
GeneralRe: Functioning with other add-ins Pin
Christoph Weber8-Mar-01 0:40
memberChristoph Weber8-Mar-01 0:40 
GeneralRe: Functioning with other add-ins Pin
Oz Solomonovich8-Mar-01 6:21
memberOz Solomonovich8-Mar-01 6:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151125.3 | Last Updated 4 Mar 2001
Article Copyright 2001 by Christoph Weber
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid