// 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;
//: