What's Special about Visual C++ .NET?
In the last 6 months, I've done two cross-Canada tours to tell developers about Visual Studio .NET and what makes it so amazing. I've delivered lines like these:
- "All those things VB programmers couldn't do -- a service, a snapin, a multithreaded app, a console app -- VB.NET programmers can do."
- "Visual C++ programmers no longer have a privileged position with the class library that gets all the goodies first. There's one class library for everyone now"
- "Language is just syntax."
Now, from the perspective of the .NET Framework, those things are certainly true. But Visual C++ .NET has something none of the other Microsoft .NET languages has: it can make ordinary Windows applications. That's right, if a Visual Basic programmer wants to make a "classic" Windows app that runs on a machine without the .NET Framework installed, it's time to dig out that old copy of VB 6. And that means the VB programmer doesn't get to use the fun toys like code outlining, flyover windows, or the server explorer while developing that app. But for Visual C++ programmers like me, there's no need to go anywhere: Visual C++ .NET makes MFC and ATL applications, just like before. It has a privileged position compared to the other .NET languages after all.
In fact, the developer team for Visual C++ had a mission statement that included something none of the other teams had: make this a great upgrade even for users who won't be building .NET applications. And they've achieved that mission. The user interface simplies some really common tasks, and reduces frustrations dramatically. (One way for me to measure this is to watch my staff as they switch back to a machine that doesn't have Visual Studio .NET on it yet, and have to do things the old way.) What's more, MFC and ATL have been improved, and so has C++ standards compliance.
How do you upgrade a Visual C++ 6 application to a Visual Studio .NET application? Simple, just open your old project file in the new product. Confirm you want to convert to the new format, Visual Studio will make you a .sln file, and nothing else will change. You'll be using the fun new user interface to do your old work. Of course, you'll have to learn your way around that fun new user interface a bit. Some old favorites are gone, and others are hard to fine.
Probably the toughest thing is that ClassWizard is gone -- you use the Properties window to catch messages now.You can see a dramatically condensed explanation of catching messages with the Properties window in Figure 1. It goes like this (the large red numbers in the figure are the order of the steps):
- In the Class View, select the class that will catch the message.
- Bring up the Properties Window if it's not up, and click the Events button -- it's a lightning bolt.
- Find the message of interest, click to expand it, and click next to COMMAND or UPDATE_COMMAND_UI as appropriate. You'll get a drop down with one choice, to add the function. You can't control the name of the function as you could in older versions of Visual C++.
- After you select the Add choice, the function will appear in the source and header files for the class, and the Class View will be updated to show the function to you. You can then add appropriate message-handling code.
What else is different? Well a lot of items have wandered from one menu to another, and some menu items only appear when you've selected the right thing in the Class View or Solution Explorer first. That can be frustrating, to say the least. The first thing you're going to want to do is to change your user profile to "Visual C++ Developer." That arranges the windows in a way that looks more like Visual C++ 6, and gives you the familiar keyboard shortcuts instead of the new Visual Studio arrangements. Simply switch to the Start Page using the tabs across the top (if you closed the Start Page, bring it back by choosing Help, Show Start Page) and click My Profile at the bottom of the left-hand column. Set your profile to "Visual C++ Developer" and things should get a lot more comfortable right away.
The first thing most Visual C++ developers ask me is "where has Project, Settings" gone to? Believe it or not, there are four ways to get to the Property Pages dialog that serves the same purpose as the old Settings dialog:
- Select the project in Solution Explorer and choose Project, Properties
- Select the project in Solution Explorer and choose View, Property Pages
- Select the project in Class View and choose Project, Properties
- Select the project in Class View and choose View, Property Pages
While there are other user interface differences between Visual C++ 6 and Visual C++ .NET, knowing how to catch messages and change your project settings should take you a long way towards feeling comfortable and productive with this amazing new tool. In the columns to come, I'll be showing you more about how to use Visual C++ .NET to build both .NET applications and classic Windows applications. And for those of you who think that poor Visual C++ has a neglected air to it, or can't do some of the things that C# and VB can do, I have a few surprises in store. See you soon!
About the Author
Kate Gregory is a founding partner of Gregory Consulting Limited (www.gregcons.com). In January 2002, she was appointed MSDN Regional Director for Toronto, Canada. Her experience with C++ stretches back to before Visual C++ existed. She is a well-known speaker and lecturer at colleges and Microsoft events on subjects such as .NET, Visual Studio, XML, UML, C++, Java, and the Internet. Kate and her colleagues at Gregory Consulting specialize in combining software develoment with Web site development to create active sites. They build quality custom and off-the-shelf software components for Web pages and other applications. Kate is the author of numerous books for Que, including Special Edition Using Visual C++ .NET.
# # #