Winapi: settextalign-set the text alignment mode of the drawing environment

Source: Internet
Author: User
// 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.
 
   
 //:


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.