Dlu? Pixel? The length unit of the control.

Source: Internet
Author: User

In the past, I rarely used VC for UI work. When I started to use VC for UI, I encountered some confusing problems.

In the dialog box editor, I initially thought that all the control length units were in pixels, and later I found that the size of the control show was significantly larger than that of the corresponding pixel, only query data can find that these lengths are in the unit of dlu.

What is dlu and dlu is the abbreviation of dialog unit, which literally means the unit of the dialog box,

How is dlu defined? This is related to the basic unit of the dialog base unit-dialog box. The basic unit of the dialog box is related to the font selected in the dialog box, the horizontal dialog base unit of the unit is probably the prime number of all characters in the font.Average width(Pixel unit), the pixel Prime Number of the vertical dialog base unit is probably all characters in the fontAverage Length(Pixel unit ).

The prime number of horizontal dlu is horizontal dlbu/4, while the prime number of horizontal dlu is vertical dlbu/8.

Aha, this is really complicated, but in general, horizontal dlu and vertical dlu are the same. When the system font and font size are 8, A dlu corresponds1.5Pixel. As for the use of other fonts and sizes, there are related APIs that can be calculated, but it is really troublesome. Fortunately, there is no chance to use it. You can check msdn if necessary.

Why is the unit of dlu used in the dialog box Editor (the length of the record to the RC resource file is also in the unit of dlu)? Naturally, when the font of the dialog box is changed,ProgramWhen loading the dialog box, the relationship between the dlu and the pixel is calculated, so as to dynamically define the size of the dialog box and the control, avoiding changing the font resulting in the string exceeding the preset length and thus invisible to the subsequent part.

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.