mfc制作具有动画效果的字体,可以设置字体

来源:互联网 发布:平胸 知乎 编辑:程序博客网 时间:2024/05/22 13:13

void CMyView::OnDraw(CDC* pDC)
{
 CMyDoc* pDoc = GetDocument();
 ASSERT_VALID(pDoc);
 // TODO: add draw code for native data here
 CRect rect;
 GetClientRect(rect);
 pDC->Ellipse(rect.Width()/2-200,rect.Height()/2-200,rect.Width()/2+200,rect.Height()/2+200);

 LOGFONT lf;
 CFont font;
 CFont *oldFont;
 lf.lfHeight=40;
 lf.lfWeight=10;
 lf.lfEscapement=m_dEscapement;
 lf.lfOrientation=m_dOrientation;
 lf.lfWeight=300;
 lf.lfItalic=FALSE;
 lf.lfUnderline=FALSE;
 lf.lfStrikeOut=FALSE;
 lf.lfCharSet=ANSI_CHARSET;
 lf.lfOutPrecision=OUT_STROKE_PRECIS;
 lf.lfClipPrecision=CLIP_STROKE_PRECIS;
 lf.lfQuality=DRAFT_QUALITY;
 lf.lfPitchAndFamily=VARIABLE_PITCH|FF_MODERN;
 strcpy(lf.lfFaceName,"仿宋_GB2312");
 font.CreateFontIndirect(&lf);
 oldFont=pDC->SelectObject(&font);
 pDC->TextOut(rect.Width()/2,rect.Height()/2,"-->---------:)");
 pDC->SelectObject(oldFont);


}

int CMyView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
 if (CView::OnCreate(lpCreateStruct) == -1)
  return -1;
 
 // TODO: Add your specialized creation code here
 SetTimer(1,1000,NULL);
 return 0;
}

void CMyView::OnDestroy()
{
 KillTimer(1);
 
 // TODO: Add your message handler code here
 
}

void CMyView::OnTimer(UINT nIDEvent)
{
 // TODO: Add your message handler code here and/or call default
 m_dEscapement=m_dEscapement-100;//顺时钟转
 m_dOrientation=m_dOrientation-100;
 Invalidate();
 CView::OnTimer(nIDEvent);
}

 

原创粉丝点击