Click here to Skip to main content
11,920,211 members (49,328 online)
Click here to Skip to main content
Add your own
alternative version


9 bookmarked

"ClassWizard" in VS.NET 2003

, 29 May 2003 CPOL
Rate this:
Please Sign up or sign in to vote.
Simulate the Class Wizard in VS.NET 2003


Visual Studio .NET 2003 brings a lot of enhancements but I sometimes miss the good ol' VC6 Class Wizard. Especially when I want to override say OnInitDialog in a CDialog derived class I find it painful to switch to the Class View, find my class in the list and finally right-click to get the Properties. So if you are like me this macro is for you!

How it works

You can use the macro from a .h or a .cpp file. If called from a .cpp file then the macro switches to the corresponding .h file. Then it searches for:

class <Whatever> 

If you are used to put the curly brace on the same line as your class declaration then you might have to change the DTE.Find.FindWhat line and remove the\n in it (see code below).

It then closes the Find dialog, synchronizes the Class View with your class and displays the Properties window. You can then click on Events/Messages/Overrides and select the function you wish to override.

Of course I mapped this to Ctrl+W!

The Macro

And here is the code!

Sub ClassWizard()

    Dim a, b As String
    a = DTE.ActiveDocument.FullName()
    tmp = InStr(a, ".cpp")
    If tmp Then
        b = Left(a, Len(a) - 3) + "h"
        DTE.Documents.Open(b, "Text")
    End If

    DTE.Find.FindWhat = "class .*\n\{"
    DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr

End Sub


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Nicolas Bonamy
Team Leader
France France
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralEhhhh Pin
Tak31-May-03 2:54
memberTak31-May-03 2:54 
GeneralRe: Ehhhh Pin
Nicolas Bonamy31-May-03 11:43
memberNicolas Bonamy31-May-03 11:43 
GeneralRe: Ehhhh Pin
Tak31-May-03 11:52
memberTak31-May-03 11:52 
GeneralRe: Ehhhh Pin
Nicolas Bonamy31-May-03 21:49
memberNicolas Bonamy31-May-03 21:49 
GeneralRe: Ehhhh Pin
Tak1-Jun-03 3:43
memberTak1-Jun-03 3:43 
GeneralRe: Ehhhh Pin
Nicolas Bonamy1-Jun-03 4:01
memberNicolas Bonamy1-Jun-03 4:01 
GeneralRe: Ehhhh Pin
Tak1-Jun-03 4:48
memberTak1-Jun-03 4:48 
GeneralRe: Ehhhh Pin
dEUs[CPP]14-Jun-03 12:15
sussdEUs[CPP]14-Jun-03 12:15 

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
Web03 | 2.8.151120.1 | Last Updated 30 May 2003
Article Copyright 2003 by Nicolas Bonamy
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid