LRESULT CALLBACK WndProc(HWND hWnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
int i;
switch (iMessage)
{
case WM_CREATE:
SetTimer(hWnd,1,50,NULL);
return 0;
case WM_TIMER:
hdc = GetDC(hWnd);
for(i = 0 ;i <1000; i++)
{
SetPixel(hdc,rand()%500,rand()%400,RGB(rand()%256,rand()%256,rand()%256));
}
return 0;
case WM_LBUTTONDOWN:
hdc = GetDC(hWnd);
Ellipse(hdc,LOWORD(lParam)-10,HIWORD(lParam)-10,LOWORD(lParam)+10,HIWORD(lParam)+10);
ReleaseDC(hWnd,hdc);
return 0;
case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
EndPaint(hWnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}
{
HDC hdc;
PAINTSTRUCT ps;
int i;
switch (iMessage)
{
case WM_CREATE:
SetTimer(hWnd,1,50,NULL);
return 0;
case WM_TIMER:
hdc = GetDC(hWnd);
for(i = 0 ;i <1000; i++)
{
SetPixel(hdc,rand()%500,rand()%400,RGB(rand()%256,rand()%256,rand()%256));
}
return 0;
case WM_LBUTTONDOWN:
hdc = GetDC(hWnd);
Ellipse(hdc,LOWORD(lParam)-10,HIWORD(lParam)-10,LOWORD(lParam)+10,HIWORD(lParam)+10);
ReleaseDC(hWnd,hdc);
return 0;
case WM_PAINT:
hdc=BeginPaint(hWnd,&ps);
EndPaint(hWnd,&ps);
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return(DefWindowProc(hWnd,iMessage,wParam,lParam));
}