Winapi: drawtext-draw text to the specified rectangle

Source: Internet
Author: User
// Declaration: drawtext (HDC: HDC; {Device handle} lpstring: pchar; {text} ncount: integer; {number of characters to be drawn;-1 indicates all} var lprect: trect; {rectangular structure} uformat: uint {Option}): integer; {returned text height} // optional value of the uformat parameter: dt_top = 0; {top alignment, required or dt_singleline} dt_left = 0; {left alignment} dt_center = 1; {horizontal center} dt_right = 2; {right alignment} dt_vcenter = 4; {vertical center, required or dt_singleline} dt_bottom = 8; {bottom alignment, required or dt_singleline} dt_wordbreak = $10; {wrap words that exceed the boundary; if the settextalign function sets ta_updatecp, invalid settings here} dt_singleline = $20; {single line text} dt_expandtabs = $40; {extended tab, default tabulation across 8 characters} dt_tabstop = $80; {number of characters added after tab} dt_noclip = $100; {leave the text within the specified rectangle} dt_externalleading = $200; {returned height includes the external line spacing of the font} dt_calcrect = $400; {automatically detects the height and width of the rectangle containing the text and returns the height, but the text is not drawn} dt_noprefix = $800; {do not process prefix characters (&); by default, & followed characters are underlined} dt_internal = $1000; {use the system font to calculate the text height} dt_hideprefix = $00100000; {hide the underline} dt_prefixonly = $00200000; {interpret & as the prefix}
 
   
 // Example: Procedure tform1.formmouseup (Sender: tobject; button: tmousebutton; shift: tshiftstate; X, Y: integer); var myrect: trect; const STR = 'delphi blog'; begin myrect. left: = x; myrect. top: = y; myrect. right: = x + 100; myrect. bottom: = Y + 100; drawtext (canvas. handle, STR,-1, myrect, dt_left); end;
  
   
 //:


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.