Skip to content

Writing Native Win32 Applications with WinLamb and Modern C++

Photo of
Hosted By
Richard T.

Details

The Win32 Windows API has been around for decades as a C API for GUI applications. At its heart, every Win32 application is a program that receives messages from Windows, decodes those messages and dispatches them to appropriate code for handling the message.

Graphical user interfaces are a natural fit for object oriented programming and C++ GUI frameworks like MFC (Microsoft Foundation Classes) were created to make writing GUI applications easier.

As Win32 applications evolved to incorporate COM (Component Object Model) objects, a need to write small components adhering to well defined interfaces became more important. Writing such components with MFC results in a heavyweight object and additional deployment dependencies. C++ libraries like ATL (Active Template Library) addressed the need to create interoperable binary components that were lightweight with minimal or no deployment dependencies.

The Windows Template Library (WTL) took the lessons learned from writing small COM objects with ATL and applied them to writing complete Win32 applications. The result is a complete library for writing Win32 applications using the static polymorphism of templates instead of the dynamic polymorphism of MFC.

Are there other ways to look at writing Win32 applications?

WinLamb is similar to WTL in that they are both header-only libraries that wrap the Win32 API. While a WTL program uses message map macros to select the appropriate handler for a message, WinLamb uses lambda functions for the message handlers and an internal dispatching mechanism.

This month, Richard Thomson will give us a walk through of using WinLamb to create Win32 applications. We'll look at how to create an application from scratch with CMake and using the project wizard in Visual Studio. (Since our application isn't cross-platform, but Windows only, we won't lose anything by using Visual Studio's wizard.)

From this skeleton application, we'll look at:

  • how to add message handlers to the main window
  • how to add controls to the main window
  • how to define and use resources
  • how to use a dialog box as the main window
  • how to create modal dialog boxes
  • how to create modeless dialog boxes
  • how to create custom controls
  • how to separate GUI logic from application logic
  • Win32 API helpers provided by WinLamb

WinLamb on github: https://github.com/rodrigocfd/winlamb
CodeProject article on WinLamb: https://www.codeproject.com/Articles/1184175/WinLamb-using-Cplusplus11-Lambdas-to-Handle-Win32

This will be an online meeting, so drinks and snacks are on you!

Join the meeting here: https://meet.xmission.com/Utah-Cpp-Programmers

Watch previous topics on the Utah C++ Programmers YouTube channel:
https://www.youtube.com/@UtahCppProgrammers

Future topics: https://utahcpp.wordpress.com/future-meeting-topics/
Past topics: https://utahcpp.wordpress.com/past-meeting-topics/

Utah C++ Programmers
Utah C++ Programmers
See more events
Online event
Link visible for attendees