Changelog: + remove escaped newlines, bogus "exit", printf's + start at a sensible size + tidy up WndProc + use a timer instead of sleeping in the message loop (Ugh!)
More patches to come...
Richard.
diff -u programs/clock0/language.c programs/clock/language.c --- programs/clock0/language.c 2002-07-02 03:09:39.000000000 +0100 +++ programs/clock/language.c 2003-07-11 15:55:42.000000000 +0100 @@ -33,11 +33,11 @@ /* analog clock */ - CheckMenuItem(Globals.hPropertiesMenu, 0x100, \ + CheckMenuItem(Globals.hPropertiesMenu, 0x100, MF_BYCOMMAND | MF_CHECKED); - CheckMenuItem(Globals.hPropertiesMenu, 0x101, \ + CheckMenuItem(Globals.hPropertiesMenu, 0x101, MF_BYCOMMAND | MF_UNCHECKED); - EnableMenuItem(Globals.hPropertiesMenu, 0x103, \ + EnableMenuItem(Globals.hPropertiesMenu, 0x103, MF_BYCOMMAND | MF_GRAYED); } else @@ -45,22 +45,22 @@ /* digital clock */ - CheckMenuItem(Globals.hPropertiesMenu, 0x100, \ + CheckMenuItem(Globals.hPropertiesMenu, 0x100, MF_BYCOMMAND | MF_UNCHECKED); - CheckMenuItem(Globals.hPropertiesMenu, 0x101, \ + CheckMenuItem(Globals.hPropertiesMenu, 0x101, MF_BYCOMMAND | MF_CHECKED); - EnableMenuItem(Globals.hPropertiesMenu, 0x103, \ + EnableMenuItem(Globals.hPropertiesMenu, 0x103, MF_BYCOMMAND); } - CheckMenuItem(Globals.hPropertiesMenu, 0x105, MF_BYCOMMAND | \ + CheckMenuItem(Globals.hPropertiesMenu, 0x105, MF_BYCOMMAND | (Globals.bWithoutTitle ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(Globals.hSystemMenu, 0x10D, MF_BYCOMMAND | \ + CheckMenuItem(Globals.hSystemMenu, 0x10D, MF_BYCOMMAND | (Globals.bAlwaysOnTop ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(Globals.hPropertiesMenu, 0x107, MF_BYCOMMAND | \ + CheckMenuItem(Globals.hPropertiesMenu, 0x107, MF_BYCOMMAND | (Globals.bSeconds ? MF_CHECKED : MF_UNCHECKED)); - CheckMenuItem(Globals.hPropertiesMenu, 0x108, MF_BYCOMMAND | \ + CheckMenuItem(Globals.hPropertiesMenu, 0x108, MF_BYCOMMAND | (Globals.bDate ? MF_CHECKED : MF_UNCHECKED)); } diff -u programs/clock0/main.c programs/clock/main.c --- programs/clock0/main.c 2002-06-01 00:40:58.000000000 +0100 +++ programs/clock/main.c 2003-07-11 15:55:42.000000000 +0100 @@ -33,6 +33,10 @@ #include "winclock.h" #include "commdlg.h" +#define INITIAL_WINDOW_SIZE 200 +#define TIMER_ID 1 +#define TIMER_PERIOD 50 /* milliseconds */ + CLOCK_GLOBALS Globals; /*********************************************************************** @@ -153,18 +157,13 @@ LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { - PAINTSTRUCT ps; - HDC context; - switch (msg) { case WM_CREATE: { - printf("WM_CREATE\n"); break; } case WM_RBUTTONUP: { - printf("WM_RBUTTONUP\n"); Globals.bWithoutTitle = !Globals.bWithoutTitle; LANGUAGE_UpdateMenuCheckmarks(); LANGUAGE_UpdateWindowCaption(); @@ -173,7 +172,9 @@ } case WM_PAINT: { - printf("WM_PAINT\n"); + PAINTSTRUCT ps; + HDC context; + context = BeginPaint(hWnd, &ps); if(Globals.bAnalog) { DrawFace(context); @@ -188,7 +189,6 @@ } case WM_SIZE: { - printf("WM_SIZE\n"); Globals.MaxX = LOWORD(lParam); Globals.MaxY = HIWORD(lParam); OldHour.DontRedraw = TRUE; @@ -202,8 +202,12 @@ break; } + case WM_TIMER: { + Idle(0); + break; + } + case WM_DESTROY: { - printf("WM_DESTROY\n"); PostQuitMessage (0); break; } @@ -211,7 +215,7 @@ default: return DefWindowProc (hWnd, msg, wParam, lParam); } - return 0l; + return 0; } @@ -257,9 +261,16 @@ if (!RegisterClass (&class)) return FALSE; + Globals.MaxX = Globals.MaxY = INITIAL_WINDOW_SIZE; Globals.hMainWnd = CreateWindow (szClassName, szWinName, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, Globals.MaxX, Globals.MaxY, 0, - LoadMenu(Globals.hInstance, STRING_MENU_Xx), Globals.hInstance, 0); + CW_USEDEFAULT, CW_USEDEFAULT, + Globals.MaxX, Globals.MaxY, 0, + 0, Globals.hInstance, 0); + + if (!SetTimer (Globals.hMainWnd, TIMER_ID, TIMER_PERIOD, NULL)) { + MessageBox(0, "No available timers", szWinName, MB_ICONEXCLAMATION | MB_OK); + return FALSE; + } LANGUAGE_LoadMenus(); SetMenu(Globals.hMainWnd, Globals.hMainMenu); @@ -269,18 +280,11 @@ ShowWindow (Globals.hMainWnd, show); UpdateWindow (Globals.hMainWnd); - while (TRUE) { - Sleep(1); - if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { - if (msg.message == WM_QUIT) return msg.wParam; - TranslateMessage(&msg); - DispatchMessage(&msg); - Idle(NULL); - } - else Idle(NULL); + while (GetMessage(&msg, 0, 0, 0)) { + TranslateMessage(&msg); + DispatchMessage(&msg); } - /* We will never reach the following statement ! */ return 0; } diff -u programs/clock0/README programs/clock/README --- programs/clock0/README 1998-09-24 04:43:38.000000000 +0100 +++ programs/clock/README 2003-07-11 15:59:54.000000000 +0100 @@ -3,13 +3,6 @@ ============== This is a first attempt to realize a desktop clock for Wine as done in - Windows. It'a an early release and most of the code is still broken. + Windows. It's an early release and some of the code is still broken. - Please see file TODO for things to do and keep the file ChangeLog - up to date. - - Code is currently under heavy construction. Please direct patches and - additions to my personal email address <mbaur@g26.ethz.ch> - - If you think that the compiled binary is too big, you can reduce its size - with the command 'strip clock' (please don't try this on libraries). + Originally contributed by <mbaur@g26.ethz.ch> Only in programs/clock/: README~ diff -u programs/clock0/TODO programs/clock/TODO --- programs/clock0/TODO 2002-03-27 21:17:01.000000000 +0000 +++ programs/clock/TODO 2003-07-11 15:55:42.000000000 +0100 @@ -8,9 +8,6 @@ - Font Handling of Digital Clock. (Does not work probably due to Winelib) -- Implement Timer Mechanism instead Polling. - Clock does not run if menu is being selected (?). - - Complete translation for the following languages : Pt,Sk - Add new .rc resources for all languages you know. That's in fact very easy. diff -u programs/clock0/winclock.c programs/clock/winclock.c --- programs/clock0/winclock.c 2002-06-01 00:40:58.000000000 +0100 +++ programs/clock/winclock.c 2003-07-11 15:55:42.000000000 +0100 @@ -205,7 +205,6 @@ GetLocalTime(&st); S = st.wSecond; - if (nLastSecond==S) { exit; } nLastSecond = S; H = st.wHour; M = st.wMinute;