[c++] How do I create a GUI for a windows application using C++?

I am deciding on how to develop a GUI for a small c++/win32 api project (working Visual Studio C++ 2008). The project will only need a few components to start off the main process so it will be very light weight (just 1 button and a text box pretty much...). My question is this:

I don't have experience developing GUIs on windows but I can learn easily. So, what should I use? A Visual editor (drag and drop code generationg: my preference for desktop GUI designing by far (java/swing)). Or should I use a speicific library? Either way, WHICH library or visual editor should I use? I heard someone mention writing the GUI in C#, then calling the C++ code... the thing is, that this is such a simple GUI I would find it easier to just keep it all in C++, but I'm open to whatever the best suggestion is.

This question is related to c++ visual-studio user-interface winapi

The answer is


A simple "window" with some text and a button is just a MessageBox. You can create them with a single function call; you don't need any library whatsoever.


I have used wxWidgets for small project and I loved it. Qt is another good choice but for commercial use you would probably need to buy a licence. If you write in C++ don't use Win32 API as you will end up making it object oriented. This is not easy and time consuming. Also Win32 API has too many macros and feels over complicated for what it offers.


For such a simple application even MFC would be overkill. If don't want to introduce another dependency just do it in plain vanilla Win32. It will be easier for you if you have never used MFC.

Check out the classic "Programming Windows" by Charles Petzold or some online tutorial (e.g. http://www.winprog.org/tutorial/) and you are ready to go.


by far the best C++ GUI library out there is Qt, it's comprehensive, easy to learn, really fast, and multiplattform.

ah, it recently got a LGPL license, so now you can download it for free and include on commercial programs


Just create a new MFC C++ app. It's built in, pretty easy, and thousands of examples exist in the world...

Plus, you can design your dialog box right in Visual Studio, give them variable names, and 90% of the code is generated for you.


I strongly prefer simply using Microsoft Visual Studio and writing a native Win32 app.

For a GUI as simple as the one that you describe, you could simply create a Dialog Box and use it as your main application window. The default application created by the Win32 Project wizard in Visual Studio actually pops a window, so you can replace that window with your Dialog Box and replace the WndProc with a similar (but simpler) DialogProc.

The question, then, is one of tools and cost. The Express Edition of Visual C++ does everything you want except actually create the Dialog Template resource. For this, you could either code it in the RC file by hand or in memory by hand. Related SO question: Windows API Dialogs without using resource files.

Or you could try one of the free resource editors that others have recommended.

Finally, the Visual Studio 2008 Standard Edition is a costlier option but gives you an integrated resource editor.


A simple "window" with some text and a button is just a MessageBox. You can create them with a single function call; you don't need any library whatsoever.


Just create a new MFC C++ app. It's built in, pretty easy, and thousands of examples exist in the world...

Plus, you can design your dialog box right in Visual Studio, give them variable names, and 90% of the code is generated for you.


I strongly prefer simply using Microsoft Visual Studio and writing a native Win32 app.

For a GUI as simple as the one that you describe, you could simply create a Dialog Box and use it as your main application window. The default application created by the Win32 Project wizard in Visual Studio actually pops a window, so you can replace that window with your Dialog Box and replace the WndProc with a similar (but simpler) DialogProc.

The question, then, is one of tools and cost. The Express Edition of Visual C++ does everything you want except actually create the Dialog Template resource. For this, you could either code it in the RC file by hand or in memory by hand. Related SO question: Windows API Dialogs without using resource files.

Or you could try one of the free resource editors that others have recommended.

Finally, the Visual Studio 2008 Standard Edition is a costlier option but gives you an integrated resource editor.


Avoid QT (for noobs) or any useless libraries (absurd for a such basic thing)

Just use the VS Win32 api Wizard, ad the button and text box...and that's all !

In 25 seconds !


If you want to learn about win32, WTL http://wtl.sourceforge.net/ is the pretty lightweight equivalent to MFC, but you have to love template to use it.

If you want something simple MFC is already integrated with VS, also it has a large base of extra code and workarounds of know bugs in the net already.

Also Qt is really great framework it have a nice set of tools, dialog editor, themes, and a lot of other stuff, plus your application will be ready to be cross platform, although it will require some time to get accustomed.

You also have Gtk, wxWindow, and you will have no problems if you have already used it on linux.


by far the best C++ GUI library out there is Qt, it's comprehensive, easy to learn, really fast, and multiplattform.

ah, it recently got a LGPL license, so now you can download it for free and include on commercial programs


A simple "window" with some text and a button is just a MessageBox. You can create them with a single function call; you don't need any library whatsoever.


Just create a new MFC C++ app. It's built in, pretty easy, and thousands of examples exist in the world...

Plus, you can design your dialog box right in Visual Studio, give them variable names, and 90% of the code is generated for you.


Avoid QT (for noobs) or any useless libraries (absurd for a such basic thing)

Just use the VS Win32 api Wizard, ad the button and text box...and that's all !

In 25 seconds !


I strongly advise against using plain Win32 because it's pretty hard to make it work OK in all situations, it's pretty dull and tedious work and the Common Controls library isn't that complete. Also, most of the work has been done for you.

Every time I end up doing plain Win32 I have to spent at least a couple of hours on the most trivial tasks because I have to look up all the parameters, flags, functions, macros and figure out how to hook them up properly. I'd generally prefer a simple drag-and-drop don't-make-me-use-my-brains type of solution and just slam the thing together in 2 minutes.

As a lightweight toolkit I'd suggest omgui which has a clean and pretty API. It doesn't, however, come with any tools.

If you need tool support, you'll probably end up wanting to go for either MFC (resource editor built into Visual Studio) or Qt. I don't know if wxWidgets has any tools, but I presume it has.

Edit: David Citron mentions that apparently the resource editor in Visual Studio generates Win32 compatible resource files, so that's probably the preferred way to do things if you wanted to keep things simple.


For such a simple application even MFC would be overkill. If don't want to introduce another dependency just do it in plain vanilla Win32. It will be easier for you if you have never used MFC.

Check out the classic "Programming Windows" by Charles Petzold or some online tutorial (e.g. http://www.winprog.org/tutorial/) and you are ready to go.


Just create a new MFC C++ app. It's built in, pretty easy, and thousands of examples exist in the world...

Plus, you can design your dialog box right in Visual Studio, give them variable names, and 90% of the code is generated for you.


I have used wxWidgets for small project and I loved it. Qt is another good choice but for commercial use you would probably need to buy a licence. If you write in C++ don't use Win32 API as you will end up making it object oriented. This is not easy and time consuming. Also Win32 API has too many macros and feels over complicated for what it offers.


I strongly prefer simply using Microsoft Visual Studio and writing a native Win32 app.

For a GUI as simple as the one that you describe, you could simply create a Dialog Box and use it as your main application window. The default application created by the Win32 Project wizard in Visual Studio actually pops a window, so you can replace that window with your Dialog Box and replace the WndProc with a similar (but simpler) DialogProc.

The question, then, is one of tools and cost. The Express Edition of Visual C++ does everything you want except actually create the Dialog Template resource. For this, you could either code it in the RC file by hand or in memory by hand. Related SO question: Windows API Dialogs without using resource files.

Or you could try one of the free resource editors that others have recommended.

Finally, the Visual Studio 2008 Standard Edition is a costlier option but gives you an integrated resource editor.


Qt from Nokia is definitely the way to go. Another option is gtk, but Qt is better supported and documented. Either way, they are both free. And both of them are widely used and well known so it is easy to find answers to your questions.


I have used wxWidgets for small project and I loved it. Qt is another good choice but for commercial use you would probably need to buy a licence. If you write in C++ don't use Win32 API as you will end up making it object oriented. This is not easy and time consuming. Also Win32 API has too many macros and feels over complicated for what it offers.


Avoid QT (for noobs) or any useless libraries (absurd for a such basic thing)

Just use the VS Win32 api Wizard, ad the button and text box...and that's all !

In 25 seconds !


Qt from Nokia is definitely the way to go. Another option is gtk, but Qt is better supported and documented. Either way, they are both free. And both of them are widely used and well known so it is easy to find answers to your questions.


For such a simple application even MFC would be overkill. If don't want to introduce another dependency just do it in plain vanilla Win32. It will be easier for you if you have never used MFC.

Check out the classic "Programming Windows" by Charles Petzold or some online tutorial (e.g. http://www.winprog.org/tutorial/) and you are ready to go.


If you want to learn about win32, WTL http://wtl.sourceforge.net/ is the pretty lightweight equivalent to MFC, but you have to love template to use it.

If you want something simple MFC is already integrated with VS, also it has a large base of extra code and workarounds of know bugs in the net already.

Also Qt is really great framework it have a nice set of tools, dialog editor, themes, and a lot of other stuff, plus your application will be ready to be cross platform, although it will require some time to get accustomed.

You also have Gtk, wxWindow, and you will have no problems if you have already used it on linux.


I strongly prefer simply using Microsoft Visual Studio and writing a native Win32 app.

For a GUI as simple as the one that you describe, you could simply create a Dialog Box and use it as your main application window. The default application created by the Win32 Project wizard in Visual Studio actually pops a window, so you can replace that window with your Dialog Box and replace the WndProc with a similar (but simpler) DialogProc.

The question, then, is one of tools and cost. The Express Edition of Visual C++ does everything you want except actually create the Dialog Template resource. For this, you could either code it in the RC file by hand or in memory by hand. Related SO question: Windows API Dialogs without using resource files.

Or you could try one of the free resource editors that others have recommended.

Finally, the Visual Studio 2008 Standard Edition is a costlier option but gives you an integrated resource editor.


I strongly advise against using plain Win32 because it's pretty hard to make it work OK in all situations, it's pretty dull and tedious work and the Common Controls library isn't that complete. Also, most of the work has been done for you.

Every time I end up doing plain Win32 I have to spent at least a couple of hours on the most trivial tasks because I have to look up all the parameters, flags, functions, macros and figure out how to hook them up properly. I'd generally prefer a simple drag-and-drop don't-make-me-use-my-brains type of solution and just slam the thing together in 2 minutes.

As a lightweight toolkit I'd suggest omgui which has a clean and pretty API. It doesn't, however, come with any tools.

If you need tool support, you'll probably end up wanting to go for either MFC (resource editor built into Visual Studio) or Qt. I don't know if wxWidgets has any tools, but I presume it has.

Edit: David Citron mentions that apparently the resource editor in Visual Studio generates Win32 compatible resource files, so that's probably the preferred way to do things if you wanted to keep things simple.


A simple "window" with some text and a button is just a MessageBox. You can create them with a single function call; you don't need any library whatsoever.


Qt from Nokia is definitely the way to go. Another option is gtk, but Qt is better supported and documented. Either way, they are both free. And both of them are widely used and well known so it is easy to find answers to your questions.


I strongly advise against using plain Win32 because it's pretty hard to make it work OK in all situations, it's pretty dull and tedious work and the Common Controls library isn't that complete. Also, most of the work has been done for you.

Every time I end up doing plain Win32 I have to spent at least a couple of hours on the most trivial tasks because I have to look up all the parameters, flags, functions, macros and figure out how to hook them up properly. I'd generally prefer a simple drag-and-drop don't-make-me-use-my-brains type of solution and just slam the thing together in 2 minutes.

As a lightweight toolkit I'd suggest omgui which has a clean and pretty API. It doesn't, however, come with any tools.

If you need tool support, you'll probably end up wanting to go for either MFC (resource editor built into Visual Studio) or Qt. I don't know if wxWidgets has any tools, but I presume it has.

Edit: David Citron mentions that apparently the resource editor in Visual Studio generates Win32 compatible resource files, so that's probably the preferred way to do things if you wanted to keep things simple.


Avoid QT (for noobs) or any useless libraries (absurd for a such basic thing)

Just use the VS Win32 api Wizard, ad the button and text box...and that's all !

In 25 seconds !


by far the best C++ GUI library out there is Qt, it's comprehensive, easy to learn, really fast, and multiplattform.

ah, it recently got a LGPL license, so now you can download it for free and include on commercial programs


If you want to learn about win32, WTL http://wtl.sourceforge.net/ is the pretty lightweight equivalent to MFC, but you have to love template to use it.

If you want something simple MFC is already integrated with VS, also it has a large base of extra code and workarounds of know bugs in the net already.

Also Qt is really great framework it have a nice set of tools, dialog editor, themes, and a lot of other stuff, plus your application will be ready to be cross platform, although it will require some time to get accustomed.

You also have Gtk, wxWindow, and you will have no problems if you have already used it on linux.


I have used wxWidgets for small project and I loved it. Qt is another good choice but for commercial use you would probably need to buy a licence. If you write in C++ don't use Win32 API as you will end up making it object oriented. This is not easy and time consuming. Also Win32 API has too many macros and feels over complicated for what it offers.


by far the best C++ GUI library out there is Qt, it's comprehensive, easy to learn, really fast, and multiplattform.

ah, it recently got a LGPL license, so now you can download it for free and include on commercial programs


For such a simple application even MFC would be overkill. If don't want to introduce another dependency just do it in plain vanilla Win32. It will be easier for you if you have never used MFC.

Check out the classic "Programming Windows" by Charles Petzold or some online tutorial (e.g. http://www.winprog.org/tutorial/) and you are ready to go.


Examples related to c++

Method Call Chaining; returning a pointer vs a reference? How can I tell if an algorithm is efficient? Difference between opening a file in binary vs text How can compare-and-swap be used for a wait-free mutual exclusion for any shared data structure? Install Qt on Ubuntu #include errors detected in vscode Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio 2017 errors on standard headers How do I check if a Key is pressed on C++

Examples related to visual-studio

VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio? How to download Visual Studio Community Edition 2015 (not 2017) Cannot open include file: 'stdio.h' - Visual Studio Community 2017 - C++ Error How to fix the error "Windows SDK version 8.1" was not found? Visual Studio Code pylint: Unable to import 'protorpc' Open the terminal in visual studio? Is Visual Studio Community a 30 day trial? How can I run NUnit tests in Visual Studio 2017? Visual Studio 2017: Display method references

Examples related to user-interface

Calling another method java GUI How do I center text vertically and horizontally in Flutter? Is it possible to put a ConstraintLayout inside a ScrollView? How to change color of the back arrow in the new material theme? How to create RecyclerView with multiple view type? Android RecyclerView addition & removal of items tkinter: how to use after method Presenting a UIAlertController properly on an iPad using iOS 8 Android ViewPager with bottom dots How do I get the height and width of the Android Navigation Bar programmatically?

Examples related to winapi

ImportError: no module named win32api Why does CreateProcess give error 193 (%1 is not a valid Win32 app) Dynamically load a function from a DLL How to check if directory exist using C++ and winAPI How to convert char* to wchar_t*? Get current cursor position Check whether a path is valid How do I link to a library with Code::Blocks? Where to find the win32api module for Python? Cannot open include file 'afxres.h' in VC2010 Express