How to create a Form in Visual C++ Projects

Spread the word!

Download and install Visual Studio from the official website.

Note: I’m using the German version of Visual Studio!

Now, go through the following steps.

3
Ctrl + N
4
Select Empty CLR Project, give it a name and click on “OK”

If you don’t see the option Visual C++ > CLR > Empty CLR Project, install the extra features called “C++/CLI Support” Desktop Development with C++ as shown here:

1

VS

So, let’s go on.

5
Select the project and go to Project > Properties

Modify these two settings:

6

7

8
Ctr+Shift+A
9
Add a Visual C++ > UI > Windows Form
10
Don’t panic. Ignore such error and restart Visual Studio

11
Open MyForm.cpp (or whatever you called it). Paste this code:

Note 1: don’t forget to chage PROJECTNAME as well as the header file MyForm.h  if different.

Note 2: even if I called the project “PROJECT_NAME” I had to delete the underscore to refer to my project in this source code. If you have doubt about it, just let you suggest the correct name from the autocomplete list:

12

You are done. Just double click on the .h file (here MyForm.h) to see your form:

13

From there you are also able to add buttons, textboxes and further elements from the Toolbox on the left.

Be the first to comment

Leave a Reply

Your email address will not be published.


*