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

📄 index151.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">CDC中的竖排文本?</font></td></tr>
<tr><td><p>
</Br>
在OnDraw成员函数中我想让文本竖直对齐,但CDC类似乎不支持该处理<Br>
</Br>
方法一:如果你的竖直对齐是指旋转文本的话,下面的代码会对你有帮助:该代码检查一个Check box控制,查看文本是否需要旋转.<Br>
</Br>
// m_pcfYTitle is a CFont* to the selected font.<Br>
// m_bTotateYTitle is a bool (==TRUE if  rotated)<Br>
</Br>
void CPage1::OnRotateytitle()<Br>
{<Br>
LOGFONT lgf;<Br>
m_pcfYTitle->GetLogFont(&lgf);<Br>
m_bRotateYTitle=<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((CButton*)GetDlgItem(IDC_ROTATEYTITLE))->GetCheck()>0;<Br>
</Br>
// escapement is reckoned clockwise in 1/10ths of a degree:<Br>
lgf.lfEscapement=-(m_bRotateYTitle*900);<Br>
m_pcfYTitle->DeleteObject();<Br>
</Br>
m_pcfYTitle->CreateFontIndirect(&lgf);<Br>
DrawSampleChart();<Br>
}<Br>
注意如果你从CFontDialog中选择了不同的字体,你应该自己设定LOGFONT的lfEscapement成员.将初始化后的lfEscapement值传到CFontDialog中.<Br>
</Br>
方法二:还有一段代码可参考:<Br>
</Br>
LOGFONT  LocalLogFont;<Br>
</Br>
strcpy(LocalLogFont.lfFaceName, TypeFace);<Br>
</Br>
LocalLogFont.lfWeight = fWeight;<Br>
LocalLogFont.lfEscapement = Orient;<Br>
LocalLogFont.lfOrientation  = Orient;<Br>
</Br>
if (MyFont.CreateFontIndirect(&LocalLogFont))<Br>
&nbsp;&nbsp;&nbsp;{<Br>
&nbsp;&nbsp;&nbsp;cMyOldFont = cdc->SelectObject(&MyFont);<Br>
&nbsp;&nbsp;&nbsp;}<Br>
</Br>
</Br>
</p></td></tr>
</table>
</body></html>

⌨️ 快捷键说明

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