⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index054.htm

📁 一本不错的VC编程的参考书
💻 HTM
字号:
<html>
<style type="text/css"><!--
.p9 {  font-family: "宋体"; font-size: 9pt}a        {text-transform: none; text-decoration: none;}
a:hover {text-decoration: underline; color: #FF0000;}
--></style>
<body background="../di2001.jpg">
<h3 align="center"><font COLOR="#AOAO99"></font></h3>
<table width="100%" border="1" cellspacing="1">
<tr><td><p align="center"><font color="#FF0000">如何显示旋转文本</font></td></tr>
<tr><td><p>
</Br>
只要用户使用TrueType或者GDI笔或字体就可以显示旋转文本(有些硬件设备也支持旋转光栅字体)。LOGFONT结构中的ifEscapement成员指定了文本行和x轴的角度,角度的单位是十分之一度而不是度,例如,ifEscapement为450表示字体旋转45度。为确保所有的字体沿坐标系统的同一方向旋转,一定要设置ifEscapement成员的CLIP_LH_ANGLES位,否则,有些字体可能反向旋转。下例使用了14点Arial字体每间隔15度画一个串。<Br>
void CSampleView:: OnDraw (CDC* pDC)<Br>
{<Br>
&nbsp;//Determine the size of the window.<Br>
&nbsp;CRect rcClient<Br>
&nbsp;GetClientRect (rcClient)<Br>
</Br>
&nbsp;//Create sample string.<Br>
&nbsp;CString str (_T ("Wheeee...I am rotating!"))<Br>
&nbsp;//Draw transparent, red text.<Br>
&nbsp;pDC->SetBkMode (TRANSPARENT)<Br>
&nbsp;pDC->SetTextColor (RGB (255,0,0))<Br>
&nbsp;CFont font<Br>
//font object<Br>
&nbsp;LOGFONT stFont //font definition<Br>
&nbsp;//Set font attributes that will not change.<Br>
&nbsp;memset (&stFont, 0, sizeof (LOGFONT))<Br>
&nbsp;stFont.ifheight=MulDiv (14, -pDC->GetDeviceCaps(LOGPIXELSY), 72)<Br>
&nbsp;stFont.ifWeight=FW_NORMAL<Br>
&nbsp;stFont.ifClipPrecision=LCIP_LH_ANGLES<Br>
&nbsp;strcpy (stFont.lfFaceName, "Arial")<Br>
</Br>
&nbsp;//Draw text at 15degree intervals.<Br>
&nbsp;for (int nAngle=0 nAngle<3600 nAngle+=150)<Br>
{<Br>
&nbsp;//Specify new angle.<Br>
&nbsp;stFont.lfEscapement=nAngle<Br>
</Br>
&nbsp;//Create and select font into dc.<Br>
&nbsp;font.CreateFontIndirect(&stfont)<Br>
&nbsp;CFont* pOldFont=pDC ->SelectObject(&font)<Br>
</Br>
&nbsp;//Draw the text.<Br>
&nbsp;pDC->SelectObject(pOldFont)<Br>
&nbsp;font.DelectObjext()<Br>
&nbsp;}<Br>
}<Br>
</Br>
</p></td></tr>
</table>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -