在Static Text控件上,实现字符串从右到左的滚动显示问题?哪位帮我看一下,有代码?

handong1978 2006-10-19 02:15:02
如题:
问题:显示后的轨迹没有刷新,有尾巴....哪位兄弟,帮我指点下!谢谢!

1、在基于对话框的界面上,加一个 Static Text控件,生成一个相应的控件对象ctrlInfo。

2、int x;


3、
BOOL CDlgTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();

.....

// TODO: Add extra initialization here
CRect re;
m_ctrlInfo.GetClientRect(&re);
x= re.Width()-2;
SetTimer(1,1000,NULL);

return TRUE; // return TRUE unless you set the focus to a control
}

void CDlgTestDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CDC* pDc = m_ctrlInfo.GetDC();
CRect re;
m_ctrlInfo.GetClientRect(&re);
m_ctrlInfo.ScreenToClient(&re);

pDc->TextOut(x,0,"hi,hello!abcdefghigklmnopqrstuvwxyz!");
x -= 50;

//m_ctrlInfo.Invalidate(FALSE);//InvalidateRect(&re);

if(x<0)
x=re.Width();
CDialog::OnTimer(nIDEvent);
}
...全文
174 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
handong1978 2006-10-19
  • 打赏
  • 举报
回复
这个方法我想到了,有没有其他方法阿?这个方法好像太不专业了!谢谢!
marrco2005 2006-10-19
  • 打赏
  • 举报
回复
pDc->TextOut(x,0,"hi,hello!abcdefghigklmnopqrstuvwxyz! ");
字符串结尾要留下足够长度的空格,用来覆盖掉尾巴,试试应该可以的

15,976

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧