CDC中的竖排文本
在OnDraw成员函数中我想让文本竖直对齐,但CDC类似乎不支持该处理
A:如果你的竖直对齐是指旋转文本的话,下面的代码会对你有帮助: 该代码检
查一个Check box控制,查看文本是否需要旋转。
素描手// m_pcfYTitle is a Cfont* to the lected font.便秘怎么揉肚子
// m_bTotateYTitle is a bool (==TRUE if rotated)
void CPage1::OnRotateytitle()
{
LOGFONT lgf;
m_pcfYTitle—〉GetLogFont(&lgf);
口语英文m_bRotateYTitle=
((Cbutton*)GetDlgItem(IDC_ROTATEYTITLE))—〉GetCheck()>0;
// escapement is reckoned clockwi in 1/10ths of a degree:
lgf.lfEscapement=—(m_bRotateYTitle*900);
m_pcfYTitle—〉DeleteObject();
番茄马铃薯m_pcfYTitle—>CreateFontIndirect(&lgf);
小康社会DrawSampleChart();
在回首}
注意如果你从CFontDialog中选择了不同的字体,你应该自己设定LOGFONT的
lfEscapement成员.将初始化后的lfEscapement值传到CFontDialog中。满架蔷薇一院香
A2:还有一段代码可参考:
LOGFONT LocalLogFont;
strcpy(LocalLogFont。lfFaceName, TypeFace);
LocalLogFont.lfWeight = fWeight;
菊花头
LocalLogFont。lfEscapement = Orient;
LocalLogFont。lfOrientation = Orient;
if (MyFont。CreateFontIndirect(&LocalLogFont))
{
cMyOldFont = cdc—〉SelectObject(&MyFont);
}