Why does winform take shape?

Source: Internet
Author: User
Why does winform take shape?

Sometimes you will find that the size of the winform program displayed on other machines is incorrect. These problems mainly occur in the background image, image box, and window layout. This is probably because of the auto-scaling feature of winform.

Because systems in different languages use different default fonts, systems with the same font may also use different DPI (characters in each inch ), traditional Win32 programs often encounter incomplete text display on different systems .. Net winform provides the auto-scale function to solve this problem. In V1.1, form has an autoscale attribute, but the scaled-down ratio attribute is incorrectly written as an integer. As a result, this system becomes a waste. In V2.0, the auto-scaling system was redesigned, And the autoscalemode attribute was added to the form base class containercontrol, providing several different auto-scaling modes to meet the needs of different types of interfaces:

1. DPI: controls are scaled down based on changes in DPI during relative design. Common DPI types are 96 and 120. This mode is only useful for some specific graphical controls.

2. Font: the control is scaled down based on the font changes during relative design. Because the ratio of width to height is often different after the font changes, this method will lead to the ratio of width to height. This mode is the default value of the EXE project. This is suitable for dialog boxes containing text labels and system controls. However, once a widget of a fixed size or a control with a high aspect ratio needs to be maintained, the original layout is easily destroyed.

3. inherit: Use the parent control mode. This option is often used for custom controls.

4. None: auto scaling is disabled. This is the only option when other modes cannot achieve reasonable results.

Msdn has a warning that DPI mode and font mode cannot be mixed in the same window. However, based on my actual experience, the automatic resizing and window layout of the dock, anchor sometimes conflict. That is to say, the current auto scaling function is still not ideal.

In fact, one of the original design goals of GDI + is to solve the text contraction problem. However, the development of GDI + has been stopped before all its functions are implemented, and it has not been accelerated by hardware. However, GDI is constantly upgraded, so that the text function of GDI + far exceeds that of GDI +. Worse, some texts, especially those in Arabic, cannot be correctly displayed or are not displayed at all in GDI +. Therefore, the winform of. NET 2.0 can only return to the GDI system again. It encapsulates the text function of GDI, that is, the textrenderer class, to provide correct, clearer, and more efficient text display.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.