VC: text format, text output function (font object, font structure variable, font output function)

Source: Internet
Author: User
Tags drawtext textout

1. Text Format

// Create a new font

LOGFONT log; // struct variable

CFont font; // font object

// Set attributes

Log. lfCharSet = ANSI_CHARSET;

Log. lfClipPrecision = 23; // specifies the font cropping precision.

Log. lfEscapement = 0; // the tilt of the font relative to the X axis is 0.

Log. lfHeight = 50; // The font height is 50.

Strcpy (log. lfFaceName, "new font"); // font name

Log. lfItalic = 0; // 0 indicates non-italic

Log. lfOrientation = 900; // The angle between the font baseline and the X axis

Log. lfOutPrecision = 90; // The output precision of the font.

Log. lfPitchAndFamily = 0; // Character Spacing

Log. lfQuality = 90; // font Output Quality

Log. lfUnderline = 0; // No underline

Log. lfStrikeOut = 0; // No strikethrough

Font. CreateFontIndirect (& log); // create a font

 

PDC-> SelectObject (& font); // select the device Environment

// Set alignment

PDC-> SetTextAlign (TA_CENTER );

// Set the output mode

PDC-> SetBkMode (TRANSPARENT );

// Set the Character spacing to 0

PDC-> SetTextCharacterExtra (0 );

PDC-> TextOut (130,100, "style 1 ");

// Set the Character spacing to 10.

PDC-> SetTextCharacterExtra (10 );

PDC-> TextOut (130,150, "Style 2 ");

2. Text Output Functions

PDC-> SetTextColor (RGB (200,0, 0 ));
Int nTab [] = {100 };
PDC-> TabbedTextOut (100, 50, "gl \ thh \ tgp", 3, nTab );
PDC-> TextOut (100,90, "this is TesOout ");
PDC-> ExtTextOut (100,130, ETO_CLIPPED, CRect (100,130,300,300), "tHis is ExTextOut", NULL );
PDC-> DrawText ("This is DrawText", CRect (100,180,300,300), DT_WORDBREAK );

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.