Visual C++ CLR Part I
This week I will be doing a five part series on Visual C++/CLR . Today I will discuss the general overview on Visual C++ and beginning to design an application.
Why Visual C++?
- Visual C++ is much easier than C++ (Mostly CLR).
- Visual C++ works just as well as C++ if the user has the .NET Framework (For CLR at least).
- A hell of a lot easier to make a GUI using the Windows Forms Designer (Only CLR).
- It is easy to convert C#/VB.NET code to Visual C++ (Only CLR again).
- Can be used as a COM DLL (I will show how in another tutorial) for use with other applications (Such as a Messenger Plus Live! Plug-in).
- Is more complicated than C# and VB.NET but worth it in the end.
- Has plenty of advantages over the other .NET languages.
The Ugly
- Only works on Windows based Systems.
- Requires .NET Framework 2.0 (Comes with Vista, separate install for Windows Operating Systems before Vista)
Prerequisites
- This will be easier if you have had some previous programming experience.
- A Windows PC (Or a Mac with a Windows Bootcamp partition).
- Visual C++ 2008 Express Edition (free and can be downloaded from here: http://www.microsoft.com/express/vc/) installed.
- Common Sense (Yes, you have to be smart for C++.
).
Getting Started
Now that you have everything ready let’s begin. Once you launch Visual C++ you will see the Start Page. Click Create Project (Under Recent Projects).
You should be greeted with the following (without my call-out):
Choose Windows Form Application (CLR should be selected under Project Types by default).
Next enter a name for the project (I’m going to use: Visual C++ - Tutorial 1)
Keep the checkbox checked under Create directory for solution. You do not need to change solution name (it will change to your project name, you can change it if you wish.)
Next click OK for the project to be created. Once it’s done creating the project, go to the next step.
Tour de IDE
Once the project is created, you should see this with Form1.h open and in Design Mode (May look a bit different, I’m using Vista).
To the left we have the Solution Explorer. It’s like a project manager, it helps you manage your project’s files. In the middle we have the code/design view. This is where you will be coding and designing your interface.
On the bottom is the Code Definition Window, this may come in handy for some (I never use it, I also don’t use the Express Edition). It shows definitions of certain parts of code. On the far right (not captured by my screen shot) is the Toolbox and Database Explorer (if you installed SQL Server Express you will see the Database Explorer). The toolbox holds all your interface design controls (We will get to this next).
Your tour is over, please step-up to your next excursion.
Designing an Interface
We have come to the easy yet overlooked part of programming, the interface. This is what the users will see, they won’t see your code (but you still want to keep it clean.
). Interfaces are often overlooked by newer programmers. The interface is an important part of your application. You want your users to feel at home and be awed by your beautiful yet simple interface. You do not want to over-blingify your interface; make it simple, make it safe.
Controls
A control in any operating system is basicly an item that the user interacts with (or a part of your interface).
Examples:
- A text box
- A picture
- A radio-button/checkbox
- Button
- Label (not really interactive but the user sees it)
Controls can be dragged from the toolbox onto the form (the little window in design view). You can also double click the control to add it to the selected form.
Review
That’s all the time I have for today. Let’s review what I have gone over today:
- Why you may want to learn Visual C++.
- What you need to get started.
- How to create a project.
- Overview on the IDE (Integrated Development Environment)
- Designing a interface. We will go more in-depth in my next tutorial.
- What controls are.
The Author
The writer of these tutorials is an eighteen year old college student named Brent Friedman. His username is "Brent" on Nystic.com’s forums. In the past he was an Administrator on Nystic, now just a simple moderator in two forum categories. He loves teaching computer information to those who do not yet have the knowledge of what he has to offer. He looks forward to teaching you more about Visual C++ in the coming weeks. Until then, stay tuned to the forum or subscribe to his blog (http://cg.nystic.com).