Creating Projects in Visual Studio
For GUI Applications


During the last few weeks of this course (see the syllabus for exact dates) we will meet in one of the CS Labs (usually N327 unless there is a class conflict and then we will meet in N326). During this time we will create five simple GUI applications using Microsoft Visual Studio. We will also look at one of those GUIs implemented in Java. The directions below give step-by-step instructions on how to create each of these projects. You should follow them carefully.


Warning: Microsoft Visual Studio does strange, unexpected things, which usually also leads to a program crash, if you try to work on a GUI project on your thumb drive. You must create the project and work on it on the C drive. When you finish working you should backup the project to your thumb drive. Do not leave work on the C drive as it is subject to being deleted, unannounced, by the system administrator.




Click on the appropriate link below for instructions on creating a project for one of the in-class exercises:









Exercise 1: A very simple first GUI program using the Windows API

  1. From the File menu select New->Project. In the New Project dialog box that appears do the following. Note: Depending on the version of Visual Studio you are using the dialog box may look slightly different.


    New Project dialog box


  2. In the Application Wizard dialog box that now appears do the following:


    Application Wizard dialog box


  3. In the Solution Explorer pane right click the project name and select Properties. In the Properties dialog box that appears do the following:


    Properties dialog box


  4. Click the back button on your browser until you are back to the page listing links to the exercises then select the Exercise 1 link and be prepared to follow along as the instructor directs you.



Exercise 2: A simple window program using the Windows API

  1. From the File menu select New->Project. In the New Project dialog box that appears do the following. Note: Depending on the version of Visual Studio you are using the dialog box may look slightly different.


    New Project dialog box


  2. In the Application Wizard dialog box that now appears do the following:


    Application Wizard dialog box


  3. In the Solution Explorer pane right click the project name and select Properties. In the Properties dialog box that appears do the following:


    Properties dialog box


  4. Click the back button on your browser until you are back to the page listing links to the exercises then select the Exercise 2 link and be prepared to follow along as the instructor directs you.



Exercise 3: A dialog based application using Microsoft Foundation Classes

There are two class exercises which use the Microsoft Foundation Classes. This first one will be a dialog based application. You should be familiar with dialog boxes but you may not know that you can create an application whose main window is a dialog box. A dialog based project in Windows is an easier way to create an application with a complex GUI.

  1. From the File menu select New->Project, or if you want to add this project to an existing solution right click the solution name in the Solution Explorer pane and select Add->New Project. In the New Project dialog box that appears do the following:


    New Project dialog box


  2. In the Application Wizard dialog box that now appears do the following:


  3. On the User Interface Features page that now appears do the following:


    Application Wizard dialog box


  4. On the Advanced Features page (see the image below) that now appears do the following:


  5. On the Generated Classes page that now appears you will see the classes that Visual Studio will automatically generate for you for the application. The image below illustrates what this will look like. The exact names of the classes will depend on the project name you chose.


    Application Wizard dialog box


  6. In the Solution Explorer pane right click the project name and select Properties. In the Properties dialog box that appears do the following:


    Properties dialog box


  7. Click the back button on your browser until you are back to the page listing links to the exercises then select the Exercise 3 link and be prepared to follow along as the instructor directs you.



Exercise 4: A Windows Forms based GUI application using Visual Studio 2010


Warning: Be aware that in previous versions of Microsoft Visual Studio there was a serious bug (probably has not been fixed by now) which can cause automatically generated Windows Forms code to produce errors which will cause the forms editor to display error messages instead of showing your form for editing.

A Google search on one of the errors will result in multiple hits including one at Microsoft where their technition states: "We are aware of this problem and isn't it good that people can meet here to discuss it." End of statement. No "solution" given. No "work around" given. No "we are working on the problem". So, expect this to possibly be a frustrating exercise. It is recommended that you create all the widgets for your form before attempting to compile or even view the source files as just switching to view the Form1.h source file can sometimes trigger the errors if you have already added widgets to the form.



  1. From the File menu select New->Project, or if you want to add this project to an existing solution right click the solution name in the Solution Explorer pane and select Add->New Project. In the New Project dialog box that appears do the following:


    New Project dialog box


  2. Visual Studio will generate a number of files for you and place them in the appropriate location in your project. It will also create the default Forms resource and open it in the resource editor as shown below.


    The Form Editor


  3. In the Solution Explorer pane right click the project name and select Properties. In the Properties dialog box that appears do the following:


    Properties dialog box


  4. Click the back button on your browser until you are back to the page listing links to the exercises then select the Exercise 4 link and be prepared to follow along as the instructor directs you.



Exercise 4: A Windows Forms based GUI application using Visual Studio 2012


Warning: For some reason Microsoft decided to remove the Windows Forms option from the Create Application dialog box so you will have to follow the instructions below to create a Windows Forms application with Visual Studio 2012.


  1. From the File menu select New->Project, or if you want to add this project to an existing solution right click the solution name in the Solution Explorer pane and select Add->New Project. In the New Project dialog box that appears do the following:


    New Project menus


  2. To add a form to the project right-click the Header Files folder in the Solution Explorer pane. In the pop-up menu select Add->New Item.


    The Form Editor


  3. In the dialog box that appears select UI under Visual C++ on the left then select Windows Form on the right. Finally, click Add.


    The Form Editor


    The form will be added and opened in the visual editor.


    The Form Editor


  4. In the Solution Explorer pane right click the project name and select Properties. In the Properties dialog box that appears do the following:


    Properties dialog box


  5. In the Solution Explorer pane of Visual Studio double click the FormName.cpp file that visual studio has created. It should already have the line #include "FormName.h" at the top. Add the code shown below to create the basic main function.


    Code for main in WinForms 2012 application


    Substitute the name of your project for WinForms2012Demo. (Note: The name of your project cannot have any spaces or special characters in it or this line will generate an error.) Also substitute the name of your form for MyForm. For example, in the instructor's demonstration of WinForms in VS 2012 this line is Demo4WinForms::Form1 form;. You can now compile and run the application to display the basic forms window.

  6. Click the back button on your browser until you are back to the page listing links to the exercises then select the Exercise 4 link and be prepared to follow along as the instructor directs you.



Exercise 4: A Windows Forms based GUI application using Visual Studio 2017


Warning: For some reason Microsoft decided to remove the Windows Forms option from the Create Application dialog box so you will have to follow the instructions below to create a Windows Forms application with Visual Studio 2017.


Click here to download a Word document showing how to create a WinForms application in VS 2017. Note: the instructor has not tried this so cannot varify it will work.



In Class Demonstration: Developing GUIs using Java on any platform

This exercise demonstrates how to develop GUIs in Java using the Eclipse compiler. You will not do this exercise in class, but the instructor will show you the code and explain how it is put together. The reason for including a Java demonstration program in a C++ class is that it is easier to visualize the Object Oriented structure of a GUI program using Java than it is in a Visual Studio GUI project.



Exercise 5: A Single Document application using Microsoft Foundation Classes

  1. From the File menu select New->Project, or if you want to add this project to an existing solution right click the solution name in the Solution Explorer pane and select Add->New Project. In the New Project dialog box that appears do the following:


    New Project dialog box


  2. In the Application Wizard dialog box that now appears do the following:


  3. On the User Interface Features page that now appears do the following:


    Application Wizard dialog box


  4. On the Advanced Features page that now appears do the following:


  5. On the Generated Classes page that now appears you will see the classes that Visual Studio will automatically generate for you for the application.
  6. In the Solution Explorer pane right click the project name and select Properties. In the Properties dialog box that appears do the following:


    Properties dialog box


  7. Click the back button on your browser until you are back to the page listing links to the exercises then select the Exercise 5 link and be prepared to follow along as the instructor directs you.