在相应的头文件中 :
CRect m_rect_parent,m_rect_web;
CStatic m_parent,m_crool;
初始化:
m_parent.GetClientRect(m_rect_parent);
m_crool.GetClientRect(m_rect_web);
// m_rect_web.Width()=m_rect_web.Width()-300;
m_crool.SetParent(&m_parent);
//CurRect.DeflateRect(0,1,m_rect_parent.Width()-m_rect_web.Width(),1);
m_crool.MoveWindow(m_rect_parent);
SetTimer(1,100,NULL);
定时器中:
if (m_rect_web.right<=m_rect_parent.left)
{
m_rect_web.left = m_rect_parent.right;
m_rect_web.right = m_rect_parent.right-m_rect_web.Width();
}
else
{
m_rect_web.left-=4;
m_rect_web.right-=4;
}
//调整控件位置
m_crool.MoveWindow(m_rect_web);
以上既可以解决简单的滚动字幕的实现;