After the announcement earlier this year, Microsoft has now officially released Windows 11 last week. Despite some issues running the new operating system on older computers due to new hardware requirements, the new version of Windows offers a nicer user experience and working environment, while maintaining a very high degree of compatibility with existing applications, including those written with Delphi and C++Builder. We are expecting a lot of end users will move to Windows 11 in the coming months.

In this blog post, I don’t want to focus on Windows 11 and its renewed user experience, but rather on how you can further improve your VCL applications to make them first class citizen in the new OS. In general terms, there are many modernization techniques Delphi and C++Builder offer to better fit with recent versions of Windows, from the use of VCL styles to the adoption to the many new VCL controls introduced over recent years (up to the ControlList and the NumberBox controls in RAD Studio 10.4.2 and the revamped RichEdit in RAD Studio 11 Alexandria).

Let’s focus on Windows 11 specific support, going even further than general migration suggestions and ideas. Windows 11 ships with the WebView2 controls, so this is a great time for adopting TEdgeBrowser over the TWebBrowser component. Also, Microsoft keeps focusing on packaged apps and the Microsoft Store, two capabilities you can achieve via RAD Studio IDE support for the MSIX deployment format. These features are in the current version of RAD Studio 11 (and were there even earlier).

New Windows 11 VCL Styles

What we have released yesterday and is now available in GetIt is a set of two new VCL styles specific to Windows 11, for light and dark mode. Type “Windows 11” in the search bar to locate them quickly:

win11_stylesingetit-6776118

Once you have installed the two styles, you can open a VCL project settings, go the Appearance page, add the styles to the application and (if you have enabled the use of VCL styles at design time), pick them in the StyleName property of a form to preview them at design time, like in the image below. Notice, among other elements, the modern style thin scrollbars in the list box.

win11_stylesindesigner-9416219

We do have some more “official” images of the two styles below, where you can see additional rounded element and colors matching the new platform defaults.

windows11light-4816822

windows11dark-4357685

Windows 11 Rounded Corners

One of the most visible elements of Windows 11 is the use of “rounded UI elements”, starting with the rounded form corners. If you create a brand new VCL application with no special configuration or setting and run it on Windows 11, you should see rounder corners for forms by default. However, this is a feature you have full control onto using a specific, public Windows API call DwmSetWindowAttribute:

To make it easier to use this API (already covered by Ian Barker in a detailed blog post titled “How To Control Windows 11 Rounded Corners In Your App“), I wrote an interposer helper class with similar code, available on GitHub at:

https://github.com/marcocantu/DelphiSessions/blob/master/Win11_Delphi11/Win11Round/Win11Forms.pas

You can see the interface section of the unit here:

win11_unitinterface-8974721

Just add this unit in the uses statement of the interface section of a form, after the Vcl.Forms unit, and your form will have a new class property indicating the default rounding and a new property for the specific form setting, so you can write:

This code works only on Windows 11, as Windows 10 or previous versions ignore it (but don’t raise any error). I used it in a simple demo (also at GitHub at https://github.com/marcocantu/DelphiSessions/tree/master/Win11_Delphi11/Win11Round) with the following UI:

win11_vclapp-4273036

Finally notice that VCL applications, including those that use the custom VCL TitleBar offer support for Snap Layouts out of the box:

win11_snap-6672888

One Small Issue and More to Come

As I mentioned earlier, VCL applications generally work fine on Windows 11. There is one issue with the coloring of menu items with associated images, given the platform uses a different set of default colors a VCL application doesn’t fully respect. This has been reported at QP https://quality.embarcadero.com/browse/RSP-35049. While there is a workaround in the Quality Portal report, we are planning to offer a fix for RAD Studio 11 for this issue shortly.

We are planning some further Windows 11 related improvements and demos of new features in the coming months and in the future RAD Studio 11.1 release. Stay tuned.

Build Applications for Windows 11 with VCL

It is not a mystery that Embarcadero used version 11 for the last release of RAD Studio to tie it with Windows 11. With all of the changes in UI libraries that Microsoft own tools underwent in recent years, I am certain that the broadness of API support and platform integration offered by the VCL library in Delphi and C++Builder is unparalleled by Microsoft Visual Studio or any third party set of tools. Microsoft has been clearly indicating native Windows development is and remains key (see Windows App SDK, aka Project Reunion) and remains the mainstream option, but their libraries in this space (like MFC and WinForms) are not on par with VCL and lag behind their own platform features.

The VCL library, with its ability to map to classic and modern APIs (from Win API, to COM-based APIs, to WinRT) and its support for High DPI monitors and modern UI trends — all without requiring a full application rewrite — is unique in the Windows desktop development scenario and clearly stands out for its power. For Windows 11 development, the Visual Component Library is the way to go.