sync to trunk head (37853) (except rbuild changes)
[reactos.git] / rostests / 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 #include <string.h>
11
12 UINT Timer = 1;
13
14 static BOOL CALLBACK DialogFunc(HWND,UINT,WPARAM,LPARAM);
15 static VOID CALLBACK TimerProc(HWND,UINT,UINT,DWORD);
16
17
18 INT STDCALL WinMain (HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR lpCmdLine, INT nCmdShow)
19 {
20 WNDCLASS wc;
21
22 ZeroMemory (& wc, sizeof wc);
23 wc.lpfnWndProc = DefDlgProc;
24 wc.cbWndExtra = DLGWINDOWEXTRA;
25 wc.hInstance = hinst;
26 wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
27 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
28 wc.lpszClassName = "CapClock";
29 RegisterClass (& wc);
30 return DialogBox(hinst, MAKEINTRESOURCE(2), NULL, DialogFunc);
31
32 }
33 static int InitializeApp (HWND hDlg,WPARAM wParam, LPARAM lParam)
34 {
35 Timer = SetTimer (hDlg,Timer,1000,TimerProc);
36 TimerProc (hDlg,0,0,0);
37 return 1;
38 }
39 static INT_PTR CALLBACK DialogFunc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
40 {
41 switch (msg)
42 {
43 case WM_INITDIALOG:
44 InitializeApp(hwndDlg,wParam,lParam);
45 return TRUE;
46 case WM_CLOSE:
47 KillTimer (hwndDlg,Timer);
48 EndDialog(hwndDlg,0);
49 return TRUE;
50 }
51 return FALSE;
52 }
53 static VOID CALLBACK TimerProc (HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
54 {
55 CHAR text [20];
56 SYSTEMTIME lt;
57
58 GetLocalTime (& lt);
59 wsprintf (
60 text,
61 "%d-%02d-%02d %02d:%02d:%02d",
62 lt.wYear,
63 lt.wMonth,
64 lt.wDay,
65 lt.wHour,
66 lt.wMinute,
67 lt.wSecond);
68 SetWindowText (hwnd, text);
69 }
70 /* EOF */