1 /* 2 * DESCRIPTION: Simple Win32 Caption Clock 3 * PROJECT : ReactOS (test applications) 4 * AUTHOR : Emanuele Aliberti 5 * DATE : 2003-09-03 6 * LICENSE : GNU GPL v2.0 7 */ 8 #include <windows.h> 9 #include <string.h> 10 11 UINT Timer = 1; 12 13 static INT_PTR CALLBACK DialogFunc(HWND,UINT,WPARAM,LPARAM); 14 static VOID CALLBACK TimerProc(HWND,UINT,UINT_PTR,DWORD); 15 16 17 INT WINAPI 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, (LPCTSTR)IDC_ARROW); 26 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); 27 wc.lpszClassName = "CapClock"; 28 RegisterClass (& wc); 29 return DialogBox(hinst, MAKEINTRESOURCE(2), NULL, 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 INT_PTR 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_PTR 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 */ 70