在客户区滚动输出一段文本串
碰到这样一个题:编写一个MDI应用程序,在客户区从左至右滚动显示文本串,我是刚自学的MFC,在网上发现这样一段代码1. 用MFC AppWizard新建一个工程 名为Q2的
2. 在CQ2VIEW类的OnDraw()函数中添加以下程序
void CQ2View::OnDraw(CDC* pDC)
{
CQ2Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
CPaintDC dc(this);
CRect r1;
LOGFONT lf;
CString outString="滚动的文字";
CBrush *OldBrush,NewBrush;
CPen *OldPen,NewPen;
CFont *OldFont,NewFont;
COLORREF strRgb[]={RGB(255,0,0),RGB(255,255,0)};
SetTimer(0,10,NULL);
SetTimer(1,100,NULL);
GetClientRect(&r1);
pDC->GetCurrentFont()->GetLogFont(&lf);
lf.lfCharSet=DEFAULT_CHARSET;
lf.lfHeight=30;
lf.lfWidth=20;
if(x>=r1.right&&i!=1)
{
x=1;
i=1;
}
else if(x>=r1.right&&i!=0)
{
x=1;
i=0;
}
if(i==1)
{
KillTimer(0);//关闭定时器0
strcpy(lf.lfFaceName,"黑体");//复制
}
else if(i==0)
{
KillTimer(1);//关闭定时器1
strcpy(lf.lfFaceName,"宋体");
}
pDC->SetBkMode(TRANSPARENT);//设置背景模式
NewFont.CreateFontIndirect(&lf);
OldFont=pDC->SelectObject(&NewFont);
NewPen.CreatePen(PS_SOLID,1,strRgb[i]);
NewBrush.CreateSolidBrush(strRgb[i]);
OldPen=pDC->SelectObject(&NewPen);
OldBrush=pDC->SelectObject(&NewBrush);
pDC->BeginPath();
pDC->TextOut(x,200,outString);
pDC->EndPath();
pDC->StrokeAndFillPath();
NewPen.DeleteObject();
NewBrush.DeleteObject();
NewFont.DeleteObject();
}
可是我不知道那个X和I表示的什么,哪位大神能够帮忙解决下啊~~~~