移动窗口
写着玩的
程序代码:#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
HWND hWnd;
RECT rect;
int iScreenWidth, iScreenHeight;
int iStepx, iStepy;
int iSpeed;
srand ( (unsigned) GetTickCount () );
iSpeed = rand () % 4 + 1;
printf ("我会移动, 你说怪不怪异?\n");
iStepx = 1;
iStepy = 1;
iScreenWidth = GetSystemMetrics (SM_CXSCREEN);
iScreenHeight = GetSystemMetrics (SM_CYSCREEN);
hWnd = GetForegroundWindow ();
SetWindowPos (hWnd, HWND_TOPMOST, 0, 0, 100, 100, SWP_NOSIZE);
while (1)
{
GetWindowRect (hWnd, &rect);
OffsetRect (&rect, iSpeed * iStepx, iSpeed * iStepy);
if ( rect.right >= iScreenWidth || rect.left <= 0 )
{
iStepx *= -1;
}
if ( rect.bottom >= iScreenHeight || rect.top <= 0 )
{
iStepy *= -1;
}
MoveWindow (hWnd, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, TRUE);
Sleep (10);
}
return 0;
}









。

看齐…………