15,979
社区成员
发帖
与我相关
我的任务
分享
int top = this.Top;
int left = this.Left;
for (int i = 1; i <= 65; i += 5)
{
this.Top= Convert.ToInt32(top + Math.Sin(i) * 5);
this.Left = Convert.ToInt32(left + Math.Cos(i) * 5);
System.Threading.Thread.Sleep(50);
}
void Move()
{
srand((unsigned)time(NULL));
HWND hWnd = ::AfxGetMainWnd()->GetSafeHwnd();
RECT rcOld, rcNew;
::GetWindowRect(hWnd, &rcOld);
POINT pt;
pt.x = rcOld.left;
pt.y = rcOld.top;
::ScreenToClient(hWnd, &pt);
::memcpy(&rcNew, &rcOld, sizeof(RECT));
int iWidth = rcOld.right-rcOld.left;
int iHeight = rcOld.bottom-rcOld.top;
int x = 0, y = 0;
for (int i =0; i<80; i++)
{
x = rand()%80-40;
y = rand()%80-40;
::MoveWindow(hWnd, rcNew.left+x, rcNew.top+y, iWidth, iHeight, TRUE);
}
::MoveWindow(hWnd, rcOld.left, rcOld.top, iWidth, iHeight, TRUE);
}