16,471
社区成员
发帖
与我相关
我的任务
分享
void RunHorseLight(CString strText, int nSpeed)
{
for(int i = 1; i < strText.GetLength(); i++)
{
CString strOneWord = strText.Mid(i - 1, 1);//注意这里只是对英文,如果是中文还得另处理,因为中文是两个字节
CString strShowText;
if(i > 1) strShowText = strText.Left(i - 1);
CString strBlankSpace = L"";
for(int j = 0;j < nSpeed - i; j++)
strBlankSpace += " ";//用空格补上能看到从右向左跑马灯的效果
for(int j = nSpeed; j > 0;j--)
{
CString strMid = strBlankSpace.Left(j);
strShowText = strShowText + strMid + strOneWord;
GetDlgItem(IDC_STATIC1)->SetWindowText(strShowText);
Sleep(600);
}
}
}