[Tips] How to display rotating text

xiaoxiao2021-03-05  23

The rotation text can be displayed as long as the user uses TrueType or GDI pen or font (some hardware devices also support rotary raster fonts). The IFESCAPEMENT member in the logfont structure specifies the angle of the text line and the X-axis, the unit of the angle is one-tenth of the degree rather than the degree, for example, ifscapement is 450 indicates 45 degrees of the font. To ensure that all fonts rotate in the same direction of the coordinate system, be sure to set the clip_lh_angles bit of the IFESCAPEMENT member, otherwise some fonts may rotate in reverse. The following example uses a 14-point Arial font to draw a string per spacer.

Void CsampleView :: OnDraw (CDC * PDC)

{

// determine the size of the window.

CRECT RCCLIENT

GetClientRect (rcclient)

// Create Sample String.cstring Str ("WHEEE ... I am Rotating!")) // Draw Transparent, Red Text.pdc-> setBkmode (Transparent) PDC-> SetTextColor (RGB (255, 0, 0 )) CFont font // font objectLOGFONT stFont // font definition // Set font attributes that will not change.memset (& stFont, 0, sizeof (LOGFONT)) stFont.ifheight = MulDiv (14, -pDC-> GetDeviceCaps (LOGPIXELSY) , 72) stfont.ifweight = fw_normalstfont.ifclipprecision = LCIP_LH_angLESSTRCPY (stfont.lffacename, "arial")

// Draw Text At 15degree Intervals.for (int Nangle = 0 Nangle <3600 Nangle = 150) {// specify new angle.stfont.lfescapement = nangle

// Create and SELECT FONTO DC.FONT.CREATEFONTINDIRECT (& Stfont) cfont * PoldFont = PDC -> SelectObject (& font)

// Draw the text.pdc-> selectobject (PoldFont) font.deelectObjext ()}

转载请注明原文地址:https://www.9cbs.com/read-39397.html

New Post(0)