VC++实现窗口抖动,代码如下
void Move()
{
srand((unsigned)time(NULL));
HWND hWnd = ::AfxGetMainWnd()->GetSafeHwnd();
RECT rcOld, rcNew;
::GetWindowRect(hWnd, &rcOld);
::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()%60-30;
y = rand()%60-30;
::MoveWindow(hWnd, rcNew.left+x, rcNew.top+y, iWidth, iHeight, TRUE);
}
::MoveWindow(hWnd, rcOld.left, rcOld.top, iWidth, iHeight, TRUE);
}