void __cdecl ThreadFun(LPVOID lpParam)
{
CTestDlg * p = (CTestDlg*)lpParam;
int i=0;
while(1)
{
i++;
CTime time = CTime::GetCurrentTime();
CString szTime = time.Format("%H:%M:%S");
p->SetWindowText(szTime.GetBuffer(szTime.GetLength()));
Sleep(1000);
if(i>=50)
break;
}
}
void CTestDlg::OnBnClickedButton7()
{
_beginthread(ThreadFun,0,this);
}VC2010编译运行
原文:http://9233403.blog.51cto.com/9223403/1970695