Modern C++ with Modern Windows

by Sep 6, 2019

This month, September 2019, Windows 10 now has over 50% market share according to VentureBeat. It passed Windows 7 in January. Windows 7, which was introduced in 2009, will have support end in January, and the message from Microsoft is clear: Windows 10 is where both Microsoft’s focus and the industry are headed.

At the same time, C++ has been progressing fast. In 2009 when Windows 7 was released, most C++ developers were still using C++98/03 (standardised in 1998 and 2003), maybe plus the Boost or TR1 libraries. Since then, C++ standards from 2011, 2014 and 2017 have been released, with many significant changes.

How do you mix modern C++ with modern Windows?

C++Builder supports C++17, the latest standard. It also has excellent Windows 10 support. Let’s look at a few items.

Windows 10 Support

C++Builder excels in UI design and quickly building, and iterating, UI applications. Its VCL framework uses native Windows controls, meaning you get the real platform behaviour, unlike some frameworks that never quite match the look and feel of the operating system the app is running on. It has many Windows 10-specific controls, often allowing them to be used on earlier versions of Windows too:

The date and time pickers, calendar controls, and so forth are the modern version of traditional controls, with the exception of the switch which is arguably new for Windows:

The card panel and stack panel controls are excellent for layout.

However, one of the most important pair of components are the TImageCollection and TVirtualImageList controls. High DPI support is a key part of Windows 10, and apps built with C++Builder support perMonitorv2 high DPI (the latest version that best supports changing resolutions across multiple screens.) A key part of high DPI applications is to have smoothly scaling icons and images, and these two components provide that in a better way than Windows’ own image lists (see docs.) They’re patented technology, and are a great example of the ultra-modern, better-than-platform technologies you can access with C++Builder.

On the left, a tiny app, unscaled. On the right, how it looks at 800%. Note how sharp the icons are – that’s something significantly harder to get in Windows without using our high DPI image handling technology.

Modern C++ Support

C++Builder 10.3.2 supports C++17 for Windows apps. Modern C++ is different from traditional (C++03 and earlier) in a couple of key ways:

  • Focus on safer and more correct code – for example, memory safety with smart pointers
  • Focus on shorter, more expressive code – for example, with lambdas
  • Focus on making it easier to write C++ – for example, with type deduction (the auto specifier)

These three things characterise the shape of C++ as it’s developed, and it’s a very powerful and flexible language. A huge number of these changes have occurred in C++11 and C++14, with more in C++17. I particularly like Tony van Eerd’s C++17 writeup and, if you want to read more about modern C++ in general, Anthony Calandra’s cheatsheet to modern C++.

C++Builder also supports, and ships with, Boost 1.68, a recent version of the most popular third party set of C++ libraries among C++ developers. If you need a library, you may find it among the 120+ libraries in Boost.

C++Builder – modern C++, and modern Windows

C++Builder gives you modern, up to date C++ with excellent, platform-surpassing support for modern Windows. Download a free trial or the free Community edition here.