With the official release of Windows 11, Embarcadero has made some specific VCL styles, and I’m offering some coding helpers specific to the new version of the Microsoft desktop OS. More will come over time.
After the announcement earlier this year, Microsoft 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 expect many end-users to move to Windows 11 in the coming months.
I don’t want to focus on Windows 11 and its renewed user experience in this blog post. but rather on how you can further improve your VCL applications to make them first-class citizens 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 of 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 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 RAD Studio 11 (and were there even earlier).
Table of Contents
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:
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.
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.
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:
1 2 |
Winapi.Dwmapi.DwmSetWindowAttribute(Handle, DWMWA_WINDOW_CORNER_PREFERENCE, @CornerPreference, sizeof(CornerPreference)); |
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:
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:
1 2 |
TForm.DefaultRoundedCorners := rcOff; // set default for all forms RoundedCorners := rcOn; // change the rounding for the current form |
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:
Finally notice that VCL applications, including those that use the custom VCL TitleBar offer support for Snap Layouts out of the box:
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 plan 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’s 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 the mainstream option. Still, their libraries in this space (like MFC and WinForms) are not on par with VCL and lag behind their 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.
Do you want to make your own VCL Forms that support Windows 11?
Try out the IDE Software and make the most of it. Request a Free Trial here.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition
I am currently modernising our 20 year old Delphi app, one of the criticisms I get is that the app looks old fashioned so all this effort being put into supporting the latest Windows styles is fantastic, especially dark styles and high dpi support with the built-in components – keep up the good work!
Hi, any news about ARM support for Linux (may be with Firemonkey)? This will be the biggest and most rewarding update.
Awesome.
Now if only Rad Studio 111 would install and not throw errors at me.. (It starts off with errors that it cannot install the .vsf files).
Still building desktop application using VCL, not just maintaining legacy ones. Keep up the great work, we still need the VCL moving forward.
On behalf of Embarcadero: thanks! VCL is a very important part of developing with RAD Studio and Marco and the team have emphasized the efforts we’re making to ensure it does indeed evolve and embrace change as Windows itself continues to iterate and surge in popularity.