Create C++ GUI project

Bryan Kelly 521 Reputation points
2025-02-13T04:21:25.4333333+00:00

Windows 11, VS Professional 2019, Version 16.11.44, C++

I want to create a project that starts up with a GUI.

Select project template:  Windows Desktop Application.  The text states:  A project for an application with a graphical user interface that runs on Windows.  The options are: C++, Windows, Desktop.

Create that project, do an immediate build and run.  It opens what looks like a console window.  It does not open a GUI.

I suspect the basic looping function to service a GUI is not present.

Look in Solution Explorer -> Header Files, Resource files, Source Files and there is nothing that looks like a blank GUI to edit. 

Look in Resource view -> Dialog and the only item there is only IDD_ABOUTBOX

Looking through all the template options does not reveal anything that looks like I need.

What are the steps to create an application with a GUI?  A GUI that can be edited with the “Toolbox” and drag and drop tools?

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | Visual Studio | Other
Developer technologies | Visual Studio | Other
A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
{count} votes

6 answers

Sort by: Most helpful
  1. RLWA32 51,361 Reputation points
    2025-02-26T08:52:07.01+00:00

    @Bryan Kelly, Please create a new MFC dialog-based project. Do NOT add ATL support.When the project has been created you should be able to build it and run it immediately and a dialog should appear as the main window as before. Close the application and return to the VS2017 IDE tht has the open MFC dialog-based project.

    In the solution explorer pane select the project. Right click and pick Add New Item. In the next dialog under Visual C++ select MFC and pick "MFC Class" as seen here -

    AddNewitemClass

    Add the new class to your project. You should now see

    AddMFCClass

    You need to make a few changes. First, change the Base class from CWnd to CDialogEx or CDialog -

    ChangeBaseClass

    After making that change you need to assign a Dialog ID -

    AddDialogID

    Now accept the changes and click the OK button. MFC will create the header file (.h) for the new dialog, its implementation code (.cpp) and will create the dialog resource. If you go to the resource view you should be able to now see the new dialog and add controls to it from the toolbox.

    AddedDialog

    Now it is up to you to add the code in your application to invoke the dialog by instantiating an instance of the new MFC class and calling its DoModal function.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.