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

111,589

Solution 1

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.

Solution 2

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

Solution 3

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.

Solution 4

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 !

Solution 5

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.

Share:
111,589

Related videos on Youtube

Sergey  Brill
Author by

Sergey Brill

Updated on July 09, 2022

Comments

  • Sergey  Brill
    Sergey Brill almost 2 years

    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.

  • sth
    sth over 15 years
    v4.5 will be LGPL licensed, but that's not released, yet.
  • Jasper Bekkers
    Jasper Bekkers over 15 years
    It does? Now you tell me :-/, that probably would have saved several years of my life.
  • jkp
    jkp over 15 years
    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.
  • pipelinecache
    pipelinecache over 15 years
    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.
  • nullException
    nullException over 15 years
    @17 of 26: not if that extra work has been done for you in the framework.
  • Sergey  Brill
    Sergey Brill over 15 years
    where can I find this win32 api wizard?
  • IInspectable
    IInspectable almost 5 years
    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
    IInspectable almost 5 years
    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).
  • Lightness Races in Orbit
    Lightness Races in Orbit almost 5 years
    "There is significant development overhead in writing code for more than one platform " lolwut
  • Vasantha Ganesh
    Vasantha Ganesh over 3 years
    @Zombies, There is Raymond Chen.
  • metablaster
    metablaster about 3 years
    Not only QT is for noobs, but is also not C++