26

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.

Tgr
  • 27,442
  • 12
  • 81
  • 118
Zombies
  • 25,039
  • 43
  • 140
  • 225
  • A tutorial from Microsoft, I think this one is really good: https://learn.microsoft.com/en-us/cpp/windows/walkthrough-creating-windows-desktop-applications-cpp?view=msvc-160 – Vasantha Ganesh Nov 11 '20 at 13:37

11 Answers11

17

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

Marc.2377
  • 7,807
  • 7
  • 51
  • 95
Javier
  • 60,510
  • 8
  • 78
  • 126
  • v4.5 will be LGPL licensed, but that's not released, yet. – sth Jan 28 '09 at 19:16
  • 2
    Major benefit of QT is that it's cross-platform. You may not think you need it now, but just wait till a few years down the line and you want to port...if you've gone with QT you'll be laughing. – jkp Jan 29 '09 at 15:57
  • 2
    Writing cross-platform code just because you _might_ want to run on multiple platforms in a few years is a terrible reason to do it. There is significant development overhead in writing code for more than one platform and you shouldn't do it unless you have a very good business case to do so. – 17 of 26 Jan 29 '09 at 16:27
  • 5
    @17 of 26: not if that extra work has been done for you in the framework. – Javier Jan 29 '09 at 19:50
  • 2
    Qt is likely the *worst* UI framework you'll find for Windows. It is poorly documented, poorly supported (even when you have a commercial support contract), and generally produces below-standard user interfaces, at a considerable investment. Don't use Qt, unless you absolutely, positively must. For Windows only, you'll produce higher quality UIs using MFC, WTL, ATL, or wxWidgets, all of which wrap the native control implementations (unlike Qt, which rolls its own, and gets it wrong just about everywhere). – IInspectable May 17 '19 at 11:27
  • _"There is significant development overhead in writing code for more than one platform "_ lolwut – Lightness Races in Orbit Jun 26 '19 at 14:07
13

If you're doing a very simple GUI and you're already using Visual Studio then it may make sense to just go with MFC. You can just use the Visual Studio MFC wizard to create a dialog based application, drop two controls on it and away you go.

MFC is dated and has its fair share of annoyances, but it will certainly do the job for you if you're just talking about a button and a text box.

I don't have any experience with Qt, so I can't compare the two.

17 of 26
  • 27,121
  • 13
  • 66
  • 85
11

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.

Community
  • 1
  • 1
David Citron
  • 43,219
  • 21
  • 62
  • 72
  • Starting with Visual Studio 2015, Microsoft is now offering *Community Editions*, as a successor to the *Express Editions*. The Community Editions are free to use, both for private as well as commercial projects, in a non-corporate environment. They contain the same features as the *Professional Editions*, including a graphical resource editor (as well as the ability to install add-ins). – IInspectable May 17 '19 at 11:41
3

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.

LarryF
  • 4,925
  • 4
  • 32
  • 40
3

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.

Jasper Bekkers
  • 6,711
  • 32
  • 46
3

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 !

2

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.

Chris
  • 4,355
  • 5
  • 20
  • 12
2

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.

devdimi
  • 2,432
  • 19
  • 18
1

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.

Ismael
  • 2,995
  • 29
  • 45
1

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.

MSalters
  • 173,980
  • 10
  • 155
  • 350
0

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.

jpastuszek
  • 799
  • 5
  • 8