Commit 9d59fb72 authored by Richard Cohen's avatar Richard Cohen Committed by Alexandre Julliard

- 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!)
parent eede817d
......@@ -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>
......@@ -8,9 +8,6 @@ Some ideas for improvements:
- 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.
......
......@@ -33,11 +33,11 @@ VOID LANGUAGE_UpdateMenuCheckmarks(VOID) {
/* 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 @@ VOID LANGUAGE_UpdateMenuCheckmarks(VOID) {
/* 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));
}
......
......@@ -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 @@ VOID MAIN_FileChooseFont(VOID) {
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 @@ LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
case WM_PAINT: {
printf("WM_PAINT\n");
PAINTSTRUCT ps;
HDC context;
context = BeginPaint(hWnd, &ps);
if(Globals.bAnalog) {
DrawFace(context);
......@@ -188,7 +189,6 @@ LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
case WM_SIZE: {
printf("WM_SIZE\n");
Globals.MaxX = LOWORD(lParam);
Globals.MaxY = HIWORD(lParam);
OldHour.DontRedraw = TRUE;
......@@ -202,8 +202,12 @@ LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
}
case WM_TIMER: {
Idle(0);
break;
}
case WM_DESTROY: {
printf("WM_DESTROY\n");
PostQuitMessage (0);
break;
}
......@@ -211,7 +215,7 @@ LRESULT WINAPI CLOCK_WndProc (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
default:
return DefWindowProc (hWnd, msg, wParam, lParam);
}
return 0l;
return 0;
}
......@@ -257,9 +261,16 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
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,10 @@ int PASCAL WinMain (HINSTANCE hInstance, HINSTANCE prev, LPSTR cmdline, int show
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;
}
......@@ -205,7 +205,6 @@ void AnalogClock(HDC dc) {
GetLocalTime(&st);
S = st.wSecond;
if (nLastSecond==S) { exit; }
nLastSecond = S;
H = st.wHour;
M = st.wMinute;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment