John Torjo - C++ Expert

Win32 GUI Generics Library

For too long, GUI programming and C++ did not mix. C++ is a complex language, and providing GUI on top of that only makes things worse...
But, there's always a solution - generic programming. Yes, Generics can bridge the gap between C++ and GUI, making C++ a RAD (Rapid Application Development).

I will gradually show you that C++ is the best language to do GUI - generics can bring data much closer to the user interface than any other language. In very few lines you'll be able to say what you want - readable, re-usable, and maintainable code.

Win32 GUI Generics - the library

The win32gui is a full-blown templated library, developed in parallel to the "Win32 GUI Generics" column, in C/C++ Users Journal.

It features:

  • real GUI RAII (Resources Acquisition Is Initialization)
  • no more message maps
  • no template code bloat
  • rookie-friendly (very easy for new users to learn it)
  • easy handling of events/ event handling
  • easy manipulation of standard controls (edit boxes, labels, list controls, ...)
  • simple manipulation of standard bars (toolbars, re-bards, status-bars)
  • thread-safety
  • enhanced dialog programming
  • easy setting of splitters (at dialog design time)
  • easy extending of existing UI window classes and/or UI behavior
  • exception-safety (a failed GUI operation won't go unnoticed - it'll throw)
  • STL-friendly
  • simple menu handling
  • enhanced enabling/disabling, checking/un-checking of menu commands
  • smart dialogs (and true binding of your data to UI controls!)
  • tooltips, bitmap buttons, tab dialogs, lite HTML controls, hyper links
  • message reflection
  • 40+ samples to get you started

Download it from here.


Win32gui' goals are very bold:

  1. Make GUI code simple and easy to understand (read and maintain)
  2. Provide GUI RAII
  3. Make GUI programming safe
  4. Make it easy to handle events and manipulate standard controls
  5. Make it easy to sub-class existing windows and to create your own windows
  6. Bring dependency on wizards to a minimum
  7. Increase dialog programming
  8. Bridge the gap between STL & GUI, allowing for truly generic solutions
  9. Make C++ a RAD (Rapid Application Development)

However, if you think I've broken any of these, just drop me an email.


I've made Win32GUI as portable as possible. However, it uses advanced templates' features, and thus you need a modern compiler in order to use it.
I have successfully tested it for VC7.1, gcc 3.3+, and Como 4.4alfa+. I intend to port it to even more modern compilers in the future.


When you download win32gui, you'll find a lot of samples. They are grouped by category. Check them out, and let me know what other examples you'd like me to provide.


Download win32gui from here. Logo