Visual C++ 2019/.NET FormApplication


Visual Studio Community 2019 can be downloaded freely from the website


To develop a Visual Studio C++ 2019/.NET Form Application, Visual Studio Community 2019 must be installed with the three options, .NET desktop development, Desktop development with C++, and C++/CLI support for v142 build tools, being checked (Figure 1). CLI (Common Language Infrastructure) is part of Microsoftfs .NET strategy.

Figure 1


After Visual Studio Community 2019 with the options marked by red rectangles in Figure 1 is installed, Start the Visual Studio. Choose gOpen a new projecth (Figure 2).

Figure 2


The gCreate a new projecth dialog window will be displayed (Figure 3).

Figure 3


Choose gCLR Empty Projecth option. CLR (Common Language Runtime) is the runtime environment in the .NET Framework.

Click the Next button. gConfigure your new projecth dialog window will be displayed (Figure 4).

Figure 4


Set names of the project and solution, and a location where the solution is put. Click on the Create button. The empty solution will be shown (Figure 5).


Figure 5


Choose menu item gProject|Add New Item...h (Figure 6).

Figure 6


gAdd New Itemh dialog window will be displayed (Figure 7).

Figure 7


Choose the menu item gVisual C++|UIh, and select the item gWindows Formh. Click the Add button.

The selected new item gWindows Formh will not be displayed. Instead, the error messages will be shown (Figure 8).

Figure 8


Simply close the solution, choosing the menu item gFile|Close Solutionh (Figure 8).

Then, open the closed solution again (Figure 9).

Figure 9


This time, the added new item gWindows Formh is successfully displayed (Figure 10).

Figure 10


To display the form during execution of the program, letfs see the code for the Windows Form. Choose the menu item gView|Codeh.

Figure 11


Code of the Windows Form will be displayed (Figure 12).

Figure 12


The file name is MyForm.h, the namespace name is Project1, and the Class name is MyForm. To prepare a code, which creates an object of the Class MyForm, choose the menu item gProject|Add New Item...h (Figure 13).

Figure 13


The gAdd New Itemh dialog window will be displayed (Figure 14).

Figure 14


Choose the menu item gVisual C++|Codeh, then select the gC++ File (.cpp)h item. Click on the Add button. The new empty code file will be added to the solution, and be displayed (Figure 15).

Figure 15


Write code as shown in Figure 16, to create and display the Form object.

Figure 16


Choose the menu item gDebug|Start Debuggingh, or press the F5 key, to execute the project. The form will be displayed as in Figure 17.

Figure 17


For further development of your .NET form application, visit this website, which is written in Japanese, but may be translated into your language by Google.

In the case of Figure 17, behind the form, a console window is also displayed. If you do not want the console window, the following settings of the project are needed.

Choose the menu item gProject|Project Propertiesh (Figure 18).

Figure 18


In the gProject Property Pagesh dialog windows, choose the menu item gLinker|Systemh. Click on the button at the right end of the gSubSystemh row.

Figure 19


Menu list will be shown. Select the item gWindows (/SUBSYSTEM:WINDOWS)h. This item will be set in the cell (Figure 20).

Figure 20


Click on the Apply button,, and on the OK button.

To set the next setting, choose the menu item gLinker|Advancedh. Set Entry Point for gmainh, the main function of the project.

Figure 21


Click on the Apply button, and the OK button.

After these two settings, the console window will not appear when the project is executed.


To learn more on development of .NET form application, visit this website.