update for HEAD-2003091401
[reactos.git] / apps / tests / capclock / capclock.c
1 /* $Id$
2  *
3  * DESCRIPTION: Simple Win32 Caption Clock
4  * PROJECT    : ReactOS (test applications)
5  * AUTHOR     : Emanuele Aliberti
6  * DATE       : 2003-09-03
7  * LICENSE    : GNU GPL v2.0
8  */
9 #include <windows.h>
10
11 UINT Timer = 1;
12
13 static BOOL CALLBACK DialogFunc(HWND,UINT,WPARAM,LPARAM);
14 static VOID CALLBACK TimerProc(HWND,UINT,UINT,DWORD);
15
16
17 INT STDCALL WinMain (HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpCmdLine, INT nCmdShow)
18 {
19         WNDCLASS wc;
20
21         ZeroMemory (& wc, sizeof wc);
22         wc.lpfnWndProc    = DefDlgProc;
23         wc.cbWndExtra     = DLGWINDOWEXTRA;
24         wc.hInstance      = hinst;
25         wc.hCursor        = LoadCursor(NULL, IDC_ARROW);
26         wc.hbrBackground  = (HBRUSH) (COLOR_WINDOW + 1);
27         wc.lpszClassName  = "CapClock";
28         RegisterClass (& wc);
29         return DialogBox(hinst, MAKEINTRESOURCE(2), NULL, (DLGPROC) DialogFunc);
30
31 }
32 static int InitializeApp (HWND hDlg,WPARAM wParam, LPARAM lParam)
33 {
34         Timer = SetTimer (hDlg,Timer,1000,TimerProc);
35         TimerProc (hDlg,0,0,0);
36         return 1;
37 }
38 static BOOL CALLBACK DialogFunc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
39 {
40         switch (msg)
41         {
42         case WM_INITDIALOG:
43                 InitializeApp(hwndDlg,wParam,lParam);
44                 return TRUE;
45         case WM_CLOSE:
46                 KillTimer (hwndDlg,Timer);
47                 EndDialog(hwndDlg,0);
48                 return TRUE;
49         }
50         return FALSE;
51 }
52 static VOID CALLBACK TimerProc (HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
53 {
54         CHAR text [20];
55         SYSTEMTIME lt;
56
57         GetLocalTime (& lt);
58         wsprintf (
59                 text,
60                 "%d-%02d-%02d %02d:%02d:%02d",
61                 lt.wYear,
62                 lt.wMonth,
63                 lt.wDay,
64                 lt.wHour,
65                 lt.wMinute,
66                 lt.wSecond);
67         SetWindowText (hwnd, text);
68 }
69 /* EOF */