6/18/10

Timer

Buzz It
#include
# define ID_TIMER 1;
long _stdcall p1(HWND,UINT,UINT,long);
WNDCLASS a;
int _stdcall WinMain(HINSTANCE i,HINSTANCE j,char *k,int l)
{
HWND h;
MSG m;
a.style =CS_HREDRAWCS_VREDRAW;
a.hbrBackground =(HBRUSH)GetStockObject(WHITE_BRUSH);
a.hCursor =LoadCursor (0,IDC_ARROW);
a.hInstance =i;
a.lpfnWndProc =p1;
a.lpszClassName ="center";
RegisterClass (&a);
h=CreateWindow ("center","press",WS_OVERLAPPEDWINDOWWS_VSCROLL,300,400,490,380,0,0,i,0);
ShowWindow (h,l);
while(GetMessage (&m,0,0,0))
{
DispatchMessage (&m);
}
return 0;
}
long _stdcall p1(HWND w,UINT x,UINT y,long z)
{
static HFONT hf;
HDC d;
PAINTSTRUCT p;
char str[100];
switch(x)
{
case WM_CREATE:
hf=CreateFont(75,50,0,0,1,0,0,0,8,0,0,0,0,"arial");
SetTimer (w,1,1000,NULL);
return 0;
case WM_TIMER:
InvalidateRect (w,NULL,TRUE);
return 0;
case WM_PAINT:
SYSTEMTIME s;
GetLocalTime (&s);
int c,v,b;
d=BeginPaint (w,&p);
c=s.wHour ;
v=s.wMinute ;
b=s.wSecond ;
SelectObject (d,hf);
wsprintf(str,"%i:%i:%i",c,v,b);
TextOut (d,10,10,str,lstrlen(str));
EndPaint (w,&p);
return 0;
case WM_DESTROY:
PostQuitMessage (0);
break;
default:
return DefWindowProc (w,x,y,z);
}
return 0;
}



Output



0 comments:

Post a Comment