Up

Programming in C++ with Visual Studio 2015

How to install and use Visual C++/.NET 2019

Installing Designer, Help and so on in Visual Studio 2017

 

On the problem as to opening a project after updating Visual Studio 2015 on July, 2016, this website will give you related information.

 

Some information to start programming in C++ with Visual Studio 2015 is presented as follows:

(1) Preparation for programming in C++

(2) Developing a simple program in C++

(3) Developing a console application in C++/CLR (.NET)

(4) Developing a form application in C++/CLR (.NET)

(5) Adding items to Toolbox

 

(1) Preparation for programming in C++

              Visual Studio Community 2015 can be downloaded and installed from the website (Figure 1.1)

https://www.visualstudio.com/downloads/download-visual-studio-vs

Figure 1.1

 

After the installation, the icon “Visual Studio 2015” will be shown (Figures 1.2, 1.3).

Figure 1.2

 

Figure 1.3

 

Click the icon, then Visual Studio will start. To develop a new program, choose the “File|New|Project…” menu item (Figure 1.4).

Figure 1.4

 

The New Project dialog window will be presented (Figure 1.5).

Figure 1.5

 

Choose the “Install Visual C++ 2015 Tools for Windows Desktop” menu item. Click the OK button, then installation of C++ tools and libraries starts.

After the steps of installation are completed, the Visual Studio is prepared for developing a program in C++. Now, choose the “File|New|Project…” menu item, then the New Project dialog window like Figure 1.6 will be presented.

Figure 1.6

 

Compare Figure 1.6 with Figure 1.5. Now, in the pane of the dialog window, templates for C++ programming are prepared.

Why these templates should be installed by the user? It is explained that C++ is very large, and overall Visual Studio install experience is significantly improved by making C++ optional.

Dev. Manager Steve Carroll says “We continue to invest heavily in C++” at the blog

https://blogs.msdn.microsoft.com/vcblog/2015/07/24/setup-changes-in-visual-studio-2015-affecting-c-developers/

 

 

(2) Developing a simple program in C++

              When developing a program in C++, choose “Empty Project” in the New Project dialog window above (Figure1.6). After setting Name, Location, and Solution name, click the OK button (Figure 1.6). A new solution, which contains an empty project, will be created. Program files will be created in the project folder named the project Name in the New Project dialog window (Figure 1.6), and the project folder is created in the solution folder named the Solution name (Figure 1.6). The solution folder is created in the folder that is set as Location in the New Project dialog window. The name of the solution is shown in the top left of the window (Figure 2.1).

Figure 2.1

 

To add a code source file to the empty project, choose the “Project|Add New Item…” menu item.

Figure 2.2

 

In the Add New Item dialog window (Figure 2.2), choose “Visual C++|Code|C++ File (.cpp).”

Set a name, then click the Add button. The text file of the name set in Figure 2.2 will be shown (Figure 2.3).

Figure 2.3

 

Write codes in C++, as shown in Figure 2.4.

Figure 2.4

 

Build (the “Build|Rebuild Project” menu item) and run (the F5 key) the program shown in Figure 2.4, then a console like Figure 2.5 will appear.

Figure 2.5

 

Press any character key. In Figure 2.6, the A key is pressed.

Figure 2.6

 

After pressing any character key, press the Enter key. Then the program will end.

 

 

(3) Developing a console application in C++/CLR (.NET)

              To create a new project, choose the “File|New|Project…” menu item. The New Project dialog window will appear (Figure 3.1).

Figure 3.1

 

Set (project’s) Name, (solution’s) Location, and Solution name, then click the OK button. A source code file will be shown (Figure 3.2).

Figure 3.2

 

When some codes are added to the program as in Figure 3.3, an error will be indicated.

Figure 3.3

 

The cause of this error is the following two lines added:

#include <iostream>

and

using namespace std;

Adding these lines,

array

in the parameter list of function main is treated as std::array, not as cli::array.

Hence, to resolve this error, add the namespace name cli to array so that we have

main( cli::array<System::String ^> ^args)

as shown in Figure 3.4.

Figure 3.4

 

As Figure 3.5 shows, a function main, which has no parameters, is also OK.

Figure 3.5

 

 

 

(4) Developing a form application in C++/CLR (.NET)

              A new form application can be created in the same way as using Visual Studio 2012 or 2013. How to create a new form application with Visual Studio 2012 is explained at the website

http://mcn-www.jwu.ac.jp/~yokamoto/openwww/vsg/VCpp2012FormApp/

or

http://mcn-www.jwu.ac.jp/~yokamoto/openwww/cpp/VCppCLR2012Form/

An error message like that of Figure 4.1, which might be presented when a new form is created by Visual Studio 2015, can be ignored.

Figure 4.1

 

To reshow the form normally, first delete the page on which the error message is shown, by clicking the X sign in the right of the tag.

Figure 4.2

 

Then, click or double click the name of the header file of the form in Solution Explorer (Figure 4.2). The form will be shown (Figure 4.3).

Figure 4.3

 

When single clicking the name, the form will be shown temporally and the pin will lie (Figure 4.3). When double clicking the name, the form will be presented normally.

 

If the error message about the form like that of Figure 4.1 is shown in spite of the above steps to display the form, delete the page of the error message, and wait until the access lamp of the disk drive, in that the project files are put, goes out. After the lamp goes out, double click the name of the form in Solution Explorer. The form will be shown successfully by the designer. It seems that Visual Studio needs some time to prepare to display the form. When these operations failed, close the solution, then reopen the solution. Click the item name of the form, i.e., “MyForm.h”, then the form will be displayed. When the source code file is shown, select the menu item “View|Designer”. The form will be displayed.

But, unfortunately, all these operations might fail. In this case, exit the Visual Studio, then restart Visual Studio and reopen the solution/project. Now, the Visual Studio would have made itself prepared to display the form by the Designer. Do the above operations again, to display the form.

 

When developing an application, Visual Studio may show various kinds of error messages, some of which can be simply ignored. Tips on these kinds of error messages are given at the website

http://mcn-www.jwu.ac.jp/~yokamoto/openwww/cpp/VCppGraphics/

 

 

(5) Adding items to Toolbox

              Not all items that can be used are listed in Toolbox. But, it is easy to add an item to Toolbox. As an example of adding an item, development of an application, which uses Windows Media Player class, is explained at this website.

An object of Windows Media Player class can play a DVD, open a picture or audio file, and so on.

 

 

Up