#include <windows.h>
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HDC myDC;
//获取屏幕分辨率
RECT ScrRect;
GetWindowRect(GetDesktopWindow(), &ScrRect);
myDC=GetDC((HWND)0); //获取设备环境
for(long i=0;i<100000L;i++)
{
int x, y, width, height;
x=(rand()%ScrRect.right)/2-(width=rand()%3); //随机产生坐标
y=rand()%ScrRect.bottom-(height=rand()%3);
BitBlt(myDC, x, y, x+width, y+height, myDC, x+rand()%3-1, y-rand()%2, SRCCOPY); //绘图
}
ReleaseDC((HWND)0, myDC);
InvalidateRect(0, NULL, TRUE);
return 0;
}


0 评论:
发表评论