Id3dxfont: drawtext

Source: Internet
Author: User
Tags drawtext truncated

Function prototype

Int drawtext (

HDC, // device description table handle

Lptstr lpstring, // string to be drawn

Int ncount, // String Length

Lprect, // pointer to the rect of the rectangular structure

Uint uformat // specifies the painting option of the body.

);

Parameters

HDC:

[Input] device environment handle.

Lpstring:

[Input] pointer to the string to be written. If the ncount parameter is-1, the string must end with/0. If uformat contains dt_modifystring, the function can add four characters to the string. The buffer for storing the string must be large enough to accommodate additional characters.

Ncount:

[Input] The number of characters in the string. If ncount is-1, the string pointed to by lpstring is considered to end with/0. drawtext automatically calculates the number of characters.

Lprect:

[Input/output] a pointer to the structure rect, which contains information about the rectangle in which the text will be placed (by logical coordinates ).

Uformat:

[Input] specifies the method for formatting text. It can be any combination of the following values. The values are described as follows:

  

Value Description
Dt_bottom Adjust the body to the bottom of the rectangle. This value must be combined with dt_singleline.
Dt_calcrect Determines the width and height of the rectangle. If the body contains multiple rows, drawtext uses the width of the rectangle defined by lprect and expands the bottom of the rectangle to accommodate the last row of the body. If the body contains only one row, drawtext changes the right boundary of the rectangle to accommodate the last character of the next line. In either of the above cases, drawtext returns the height of the formatted body, rather than the body.
Dt_center Center the body horizontally in the rectangle.
Dt_vcenter Center the body vertically in the rectangle. (Dreamsmart note: this parameter must be used with dt_single; otherwise, GDI cannot calculate the destination rectangle)
Dt_editcontrol Copy the text display feature of the multi-row editing control. In particular, the average character width for editing control is calculated in the same way. This function does not display only the last partially visible line.
Dt_end_ellipsis For the displayed text, if the range of the ending string is not within the rectangle, It is truncated and appended to the ellipse. If a letter is not at the end of a string beyond the rectangle range, it will not be truncated by an ellipse. The string is not modified unless the dt_modifystring flag is specified.
Dt_expandtabs Extended tabs. The default number of characters for each tab is 8. Dt_word_ellipsis, dt_path_ellipsis and dt_end_ellipsis cannot be used with this parameter
Dt_externalleading The height of a row contains the external header of the font. Generally, the external header is not included in the height of the body row.
Dt_hideprefix Ignore the prefix characters (&) in the body, and the letters after the prefix characters do not contain underscores. The call method of other prefix characters is not affected. Input string: "A & BC & D" Normal: "ABC & D" dt_hideprefix: "ABC & D"
Dt_internal The system font is used to calculate the body measurement.
Dt_left The text is left aligned.
Dt_modifystring Modify the given string to match the displayed body. This flag must be used together with dt_end_ellipsis or dt_path_ellipsis.
Dt_noclip No cropping. When dt_noclip is used, the use of drawtext will be accelerated.
Dt_nofullwidthcharbreak To prevent line breaking in string with wide characters, the line breaking rule is equivalent to a single character string. For example, we can use it in Windows to provide better readability for icon labels. This value does not work unless dt_wordbreak is specified.
Dt_noprefix Disable prefix character processing. Generally, drawtext is used to explain the prefix of the mnemonic character. & it is used to underline the character after it, and the description & is used to display a single &. Specify dt_noprefix, Which is disabled.
Dt_path_ellipsis For the displayed body, replace the character string in the ellipse to ensure that the result is within the appropriate rectangle. If the string contains the backslash (/) character, dt_path_ellipsis tries its best to retain the body after the last backslash. The string is not modified unless the dt_modifystring flag is specified.
Dt_prefixonly Only draw an underline at the position of the (&) prefix. No other characters in the string are drawn. Input string: "A & BC & D" Normal: "ABC & D" dt_prefixonly :"_"
Dt_right Right-aligned text.
Dt_rtlreading When the font selected for the device environment is a Hebrew or Arabic font, the order of reading from right to left for the bidirectional body is from left to right.
Dt_singleline If the same line of the text is displayed, the carriage return and line break cannot be broken.
Dt_tabstop Set tabulation. The uformat parameter's 15 "C8 bits (the high byte in the low-level word) specifies the number of characters for each tab. The default number of characters for each tab is 8. Note: dt_calcrect, dt_externalleading, dt_internal, dt_noclip, and dt_noprefix values cannot be used with dt_tabstop values.
Dt_top Align the top of the body (only for a single row ).
Dt_wordbreak Disconnect a word. When the characters in a row extend to the border of the rectangle specified by lprect, this row is automatically broken between words. A carriage return and a line feed can also break the line.
Dt_word_ellipsis Truncates the text that does not conform to the rectangle and adds an elliptic.

Return Value

If the function is successfully called, the return value is the height of the body (logical unit ). If dt_vcenter or dt_bottom is specified, the return value is the offset value from lprect-> top to the bottom of the drawn body.

If the function call fails, the returned value is 0.

Windows NT: To obtain more error information, call the getlasterror function.


Remarks

The drawtext function uses the font selection, body color, and background color in the device environment to write the body. Drawtext crops the body and does not appear outside the specified rectangle unless dt_noclip is specified. Unless formatted using dt_singleline, the rest of the formats are considered to have multiple lines of the body.

If the selected font is too large for the specified rectangle, drawtext will not try to replace it with a small font.

Drawtext supports fonts with both vertical and direction 0.

The text alignment of the device environment must include the ta_left, ta_top, and ta_noupdatecp labels.

Windows CE: If you specify the dt_calcrect value for the uformat parameter, you must set the right and bottom members for the rect structure pointed to by lprect. Windows CE does not support uformat as dt_externalleading.

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.