我上次发的那个线程创建,已经解决,稍后会结贴。现在 ,又发现在一个新的问题,就是什么都过去了。没有任何错误,程序也正常执行了。但是,执行一段时间后,就变成白屏了。像屏保,但是,动鼠标也没有办法。哎。为什么受伤的总是我。请指教。DWORD WINAPI BallMove(LPVOID lpparameter)
{
LPINFO temp=(LPINFO)lpparameter;
BOOL xadd,yadd;
xadd=yadd=TRUE;
while(TRUE)
{
if((temp->xPos+temp->ballr)>=((LPRECT)temp->rect)->right)
xadd=FALSE;
else if((temp->xPos-temp->ballr)<=((LPRECT)temp->rect)->left)
xadd=TRUE;
if((temp->yPos+temp->ballr)>=((LPRECT)temp->rect)->bottom)
yadd=FALSE;
else if((temp->yPos-temp->ballr)<=((LPRECT)temp->rect)->top)
yadd=TRUE;
if(xadd)
temp->xPos++;
else
temp->xPos--;
if(yadd)
temp->yPos++;
else
temp->yPos--;
CRect rect(temp->xPos-temp->ballr-2,temp->yPos-temp->ballr-2,temp->xPos+temp->ballr+2,temp->yPos+temp->ballr+2);
InvalidateRect(temp->hWnd,rect,TRUE);
Sleep(temp->speed);
}
return 0;
}
省略一些。
m_hGreenThread=CreateThread(NULL,0,BallMove,&m_GreenBall,0,&ThreadID);