// Declaration: settextalign (DC: HDC; {Device environment handle} flags: uint {alignment options}): uint; {return alignment options; if gdi_error is returned, it indicates the setting Failed} // optional value of the flags parameter: ta_noupdatecp = 0; {the current location is not updated after each text output} ta_updatecp = 1; {after each text output, update the current position} ta_left = 0; {starting from the left side of the text external rectangle} ta_right = 2; {starting from the right side of the text external rectangle} ta_center = 6; {start at the horizontal center of the text external rectangle} ta_top = 0; {start at the top side of the text external rectangle} ta_bottom = 8; {start at the bottom side of the text external rectangle} ta_baseline = 24; {start at text baseline} ta_rtlreading = $100; {text order from right to left, only for special languages} vta_baseline = ta_baseline; {vertical baseline} vta_left = ta_bottom; vta_right = ta_top; vta_center = ta_center; {vertical center} vta_bottom = ta_right; vta_top = ta_left;
// Example: Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls, extctrls; Type tform1 = Class (tform) radiogroup1: tradiogroup; radiogroup2: tradiogroup; Procedure formpaint (Sender: tobject); Procedure radiogroup1click (Sender: tobject); procedure invoke (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} var H: Cardinal = 0; V: Cardinal = 0; Procedure tform1.formpaint (Sender: tobject); var DC: HDC; X, Y: integer; const STR = 'delphi blog'; begin DC: = canvas. handle; X: = clientwidth Div 2; Y: = clientheight Div 2; settextalign (DC, H or V); textout (DC, X, Y, STR, length (STR); end; Procedure tform1.radiogroup1click (Sender: tobject); begin case radiogroup1.itemindex of 0: H: = ta_left; 1: H: = ta_center; 2: H: = ta_right; end; self. repaint; end; Procedure tform1.radiogroup2click (Sender: tobject); begin case radiogroup2.itemindex of 0: V: = ta_top; 1: V: = vta_center; 2: V: = ta_bottom; end; self. repaint; end.
//: