Write a Window program to display random rectangle.
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
static x,y,x1,y1;
switch (message)
{
case WM_CREATE:
SetTimer(hWnd,1,1000,NULL);
return 0;
case WM_TIMER:
hdc=GetDC(hWnd);
x=rand()%500;
y=rand()%500;
x1=x+100;
y1=y+100;
Rectangle(hdc,x,y,x1,y1);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
Comments
Post a Comment