Windows Forms updated for .NET 6.0 • The registry

Microsoft’s oldest .NET desktop framework, Windows Forms, has been enhanced for .NET 6, although full support for high-resolution displays is “a tough endeavor,” according to software engineer Igor Velikorossov.

The first release of Windows Forms dates from February 2002, when it positioned itself as the successor to Visual Basic 6.0 (1998) as a rapid application development framework for Windows desktop applications. There was enormous friction during this transition, but it was popular and easy to use nonetheless. Under Windows Forms are the Win32 API and the GDI + graphics API.

In late 2006, Microsoft introduced Windows Vista and with it a new .NET desktop framework called Windows Presentation Foundation (WPF). Unlike Windows Forms, it used DirectX for rendering graphics, enabling richer designs with accelerated hardware performance.

WPF was also designed for good scaling regardless of Windows display resolution and display settings, through the use of layout managers to position UI elements.

Windows Forms in Visual Studio 2022

Windows Forms in Visual Studio 2022

Why is Microsoft still investing in Windows Forms, the oldest .NET desktop framework, when it has been replaced several times, first by WPF, then by Windows 8 with its Windows Runtime APIs, then by UWP (Universal Windows Platform), and more recently by WinUI 3 (also known as Project Reunion)? The answer is simply the popularity of the framework and the number of legacy business applications that use it. Third-party component vendors have also provided good support for the platform.

It seems that despite WPF’s technical superiority, many commercial developers find Windows Forms easier, perhaps because of its seemingly simple form designer where a button or checkbox stays where it’s placed, at least until the end. ‘Users with different display settings complain about overlapping text or broken characters.

Windows Forms is only for Windows and not much has been done for a few years, especially since it was for the .NET Framework and most of the development effort went into open source .NET Core. . That changed when .NET Core 3.0 was released, with support for both Windows Forms and WPF. At this point both frameworks have become open source, although it is a fork and Velikorossov’s post on what’s new in Windows Forms is for the .NET 6.0 version, not the .NET Framework version.

Migrating from an existing application is not straightforward and may not be possible without major surgery.

Some features of the .NET Framework include Application Domains, .NET Remoting, Windows Workflow Foundation, and Windows Communication Foundation (WCF), with WCF being the most problematic.

Remote communication using SOAP (an XML remote communication standard) and WCF was widely used, often with ASP.NET on the web server and a Windows Forms client.

Despite these issues, Microsoft has added features including accessibility improvements such as better screen narrator support and user interface automation, updated templates to support the new .NET 6.0 global usage guideline and new runtime designers. “In .NET Core 3.0, we started to modernize and rejuvenate Windows Forms,” Velikorossov said.

The biggest challenge remains the scaling and high DPI (dots per inch) displays. The original scaling method for Windows Forms was based on the default system font, the size of which depended on all of a form’s autoscaling. It was not a good system. There were rounding errors, problems with user controls and with form inheritance, and “forms and their child controls could only be designed by multiple developers simultaneously if their machines had the same resolutions.” , say the docs.

There were some tweaks, but high DPI support only arrived with the .NET Framework 4.7 and only worked on Windows 10 Creators Update and later. When the .NET Core version arrived, Velikorossov describes how the team changed the default font and “quickly learned that a lot of things depended on this default font metric.”

The goal of full support for DPI V2 consideration per monitor remains, meaning that applications are never bitmap scaled by Windows (causing blurry fonts) but are notified when the DPI changes, possibly due to a parameter change or a window dragged to another display. “It’s a tough business, and unfortunately we weren’t able to achieve as much as we had hoped,” said Velikorossov, but there are improvements with proper scaling of container controls and MDI child windows “in most scenarios”.

There are also community contributions to Windows Forms for .NET 6.0, including MessageBox, used for quick dialogs that require confirmation or user input, eventually getting two new buttons: Retry and Continue.

The developers reacted to Velikorossov’s post with a few requests. “Please add native dark mode” was one of them, although apparently a challenge here was that “Windows still does not have a documented way to check if the system is in light or dark mode”. Another gratefully commented that “Form Designer in the VS 2022 version works much better, it was way too slow”.

When the .NET Foundation conducted a developer survey earlier this year, WPF and Windows Forms were found to be more widely used than Microsoft’s more recent efforts.

It’s not a good choice for a graphics application today, being Windows only and a weak option even on Windows, but the legacy combined with its initial ease of use means it will be around for many years to come. coming, which developers are less sure about with other .NET technologies. ®

Source link

About Dwayne Wakefield

Check Also

Importers have a 24 hour window to clear goods before benchmarks are removed

Economic news for Wednesday 5 January 2022 Source: www.ghanaweb.com 2022-01-05 President of the Association of …