Commits

overlord  committed 485115f

Universal Time Stamp Display Clock

  • Participants

Comments (0)

Files changed (10)

+#ifndef __INC_GLBLS_H
+#define __INC_GLBLS_H
+/*-------------------------------------------------------------------------*/
+extern HINSTANCE _HInstance; /* global instance handle / base address */
+extern int _nCmdShow; /* window show parameter from cmd line */
+#if defined(_Windows) && !defined(BI_PLAT_WIN32) && !defined(__WIN32__)
+extern HINSTANCE _HPrevInst; /* handle of previous app instance (Win16 only) */
+#endif
+
+/* functions */
+#ifdef __cplusplus
+extern "C" {
+#endif /*__cplusplus*/
+
+void CClassGlobalConstruct(void);
+void CClassGlobalDestruct(void);
+
+#ifdef __cplusplus
+} /* end extern "C"s */
+#endif /*__cplusplus*/
+/*-------------------------------------------------------------------------*/
+#endif /*__INC_GLBLS_H*/
+#ifndef __INC_MAINWIN_H
+#define __INC_MAINWIN_H
+/*-------------------------------------------------------------------------*/
+typedef struct _S_MAINWINDOW
+{
+	/* private - DO NOT TOUCH */
+   WNDCLASS _classInfo;
+   HWND _handle; /* handle of window */
+   char* _caption; /* caption of the window */
+   int _width; /* width of window */
+   int _height; /* height of window */
+   int _top; /* top of window */
+   int _left; /* left of window */
+   BOOL _visible; /* Specifies if the window is currently visible */
+   BOOL _reshow; /* Set to TRUE on first show, so show can see a reshow */
+   HMENU _menu; /* stores dynamic menu resource handle for destruction */
+   int _clientHeight, _clientWidth; /* client (drawing area) limits */
+
+   /* public - For external use and internal use */
+   HWND (*GetHandle)(void*); /* gets the window handle of the window */
+   const char* (*GetCaption)(void*); /* gets the caption of the window */
+   const char* (*SetCaption)(void*, const char* NewCaption); /* sets the window caption */
+   int (*GetWidth)(void*);
+   int (*SetWidth)(void*, int NewWidth); /* Sets width, returns old width */
+   int (*GetHeight)(void*);
+   int (*SetHeight)(void*, int NewHeight); /* sets height, returns old height */
+   int (*GetTop)(void*);
+   int (*GetLeft)(void*);
+   int (*SetTop)(void*, int NewTop);
+   int (*SetLeft)(void*, int NewLeft);
+   BOOL (*IsVisible)(void*); /* returns _visible */
+   BOOL (*Show)(void*); /* shows the window, rets FALSE if already so */
+   BOOL (*Hide)(void*); /* hides the window, rets FALSE if not visible */
+   void (*Repaint)(void*); /* repaints the window */
+   void (*UpdateWindowPos)(void*); /* updates the window's position on the screen, the dimentions should have changed or you'll be wasting time */
+   int (*GetClientWidth)(void*); /* returns the drawing area of the window's max X extent +1 */
+   int (*GetClientHeight)(void*); /* returns the drawing area of the window's max Y extent +1 */
+   void (*RestrictSize)(void*, MINMAXINFO FAR*);
+} S_MAINWINDOW, *S_PMAINWINDOW;
+
+#ifdef __cplusplus
+extern "C" {
+#endif /*__cplusplus*/
+
+/* manual C constructor/destructor for S_MAINWINDOW objects */
+void MainWindow_Construct( S_PMAINWINDOW Pobject);
+void MainWindow_Destruct(S_PMAINWINDOW Pobject);
+/* hooked members */
+HWND MainWindow_GetHandle(void* parent); /* gets the window handle of the window */
+const char* MainWindow_GetCaption(void* parent); /* gets the caption of the window */
+const char* MainWindow_SetCaption(void* parent, const char* NewCaption); /* sets the window caption */
+int MainWindow_GetWidth(void* parent);
+int MainWindow_SetWidth(void* parent, int NewWidth); /* Sets width, returns old width */
+int MainWindow_GetHeight(void* parent);
+int MainWindow_SetHeight(void* parent, int NewHeight); /* sets height, returns old height */
+int MainWindow_GetTop(void* parent);
+int MainWindow_GetLeft(void* parent);
+int MainWindow_SetTop(void* parent, int NewTop);
+int MainWindow_SetLeft(void* parent, int NewLeft);
+BOOL MainWindow_IsVisible(void* parent); /* returns _visible */
+BOOL MainWindow_Show(void* parent); /* shows the window, rets FALSE if already so */
+BOOL MainWindow_Hide(void* parent); /* hides the window, rets FALSE if not visible */
+void MainWindow_Repaint(void* parent); /* reapaints the window */
+void MainWindow_UpdateWindowPos(void* parent); /* The window is positioned and sized to the data members */
+int MainWindow_GetClientWidth(void* parent);
+int MainWindow_GetClientHeight(void* parent);
+void MainWindow_RestrictSize(void* parent, MINMAXINFO FAR* PMinMaxInfo);
+/* non-hooked members */
+LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); /* windowing procedure */
+
+#ifdef __cplusplus
+} /* end extern "c"s */
+#endif /*__cplusplus*/
+/*-------------------------------------------------------------------------*/
+extern S_MAINWINDOW MainWindow; /* the main window (instance) */
+/*-------------------------------------------------------------------------*/
+#endif /*__INC_MAINWIN_H*/
+#ifndef __INC_UTClock_H
+#define __INC_UTClock_H
+/*-------------------------------------------------------------------------*/
+/* (nothing) */
+/*-------------------------------------------------------------------------*/
+#endif /*__INC_UTClock_H*/
+#ifndef __INC_UTCLOCK_RH
+#define __INC_UTCLOCK_RH
+
+#define IDM_MAINMENU	(1)
+#define CM_WINDOW_EXIT	(11843)
+#define CM_WINDOW_REPAINT	(11842)
+#define CM_HELP_ABOUT	(18873)
+#define IDI_CLOCK		(11844)
+#define VERSIONINFO_1	(1)
+
+#endif /*__INC_UTCLOCK_RH*/

File UtClock.ide

Binary file added.
+#include <Windows.H>
+#pragma hdrstop
+
+#include "MainWin.H"
+#include "Glbls.H" /* our header */
+/*-------------------------------------------------------------------------*/
+HINSTANCE _HInstance;
+int _nCmdShow;
+#if defined(_Windows) && !defined(BI_PLAT_WIN32) && !defined(__WIN32__)
+HINSTANCE _HPrevInst; /* handle of previous instance (Win16 only) */
+#endif
+/*-------------------------------------------------------------------------*/
+void CClassGlobalConstruct(void)
+{
+	MainWindow_Construct(&MainWindow); /* construct the main window */
+}
+/*-------------------------------------------------------------------------*/
+void CClassGlobalDestruct(void)
+{
+	MainWindow_Destruct(&MainWindow); /* destroy the main window */
+}
+/*-------------------------------------------------------------------------*/
+/* Code to handle the main window */
+#include <Windows.H>
+#include <String.H>
+#include <StdLib.H>
+#pragma hdrstop
+
+#include "UTClock.RH" /* resources */
+#include "MainWin.H" /* ours */
+#include "Glbls.H" /* globals */
+
+S_MAINWINDOW MainWindow; /* the main window (instance) */
+/*-------------------------------------------------------------------------*/
+void MainWindow_Construct( S_PMAINWINDOW Pobject)
+{
+	/* local vars */
+   CREATESTRUCT cs; /* window creation info */
+   const char defCap[] = "Universal Time Counter"; /* default caption of window */
+
+	/* member hookup */
+   Pobject->GetHandle = MainWindow_GetHandle;
+   Pobject->GetCaption = MainWindow_GetCaption;
+   Pobject->SetCaption = MainWindow_SetCaption;
+   Pobject->GetWidth = MainWindow_GetWidth;
+   Pobject->SetWidth = MainWindow_SetWidth;
+   Pobject->GetHeight = MainWindow_GetHeight;
+   Pobject->SetHeight = MainWindow_SetHeight;
+   Pobject->GetTop = MainWindow_GetTop;
+   Pobject->GetLeft = MainWindow_GetLeft;
+   Pobject->SetTop = MainWindow_SetTop;
+   Pobject->SetLeft = MainWindow_SetLeft;
+   Pobject->IsVisible = MainWindow_IsVisible;
+   Pobject->Show = MainWindow_Show;
+   Pobject->Hide = MainWindow_Hide;
+   Pobject->Repaint = MainWindow_Repaint;
+   Pobject->UpdateWindowPos = MainWindow_UpdateWindowPos;
+   Pobject->GetClientWidth = MainWindow_GetClientWidth;
+   Pobject->GetClientHeight = MainWindow_GetClientHeight;
+   Pobject->RestrictSize = MainWindow_RestrictSize;
+
+   /* defaults */
+   Pobject->_handle = NULL;
+   Pobject->_visible = FALSE; /* hidden before created */
+   Pobject->_reshow = FALSE; /* not shown yet */
+   Pobject->_clientHeight = 0; /* N/A */
+   Pobject->_clientWidth = 0; /* N/A */
+
+   /* set the default caption of the window */
+   Pobject->_caption = (char*)malloc(strlen(defCap)+1);
+   strcpy(Pobject->_caption, defCap);
+
+   Pobject->_width = CW_USEDEFAULT;
+   Pobject->_height = CW_USEDEFAULT;
+   Pobject->_top = CW_USEDEFAULT;
+   Pobject->_left = CW_USEDEFAULT;
+
+   Pobject->_classInfo.style = CS_HREDRAW | CS_VREDRAW;
+   Pobject->_classInfo.lpfnWndProc = MainWndProc;
+   Pobject->_classInfo.hInstance = _HInstance; /* identifies us */
+   Pobject->_classInfo.hIcon = LoadIcon(_HInstance, MAKEINTRESOURCE(IDI_CLOCK));
+   Pobject->_classInfo.hCursor = LoadCursor(NULL, IDC_ARROW);
+   Pobject->_classInfo.hbrBackground = (HBRUSH)COLOR_WINDOW;
+   Pobject->_classInfo.lpszMenuName = MAKEINTRESOURCE(IDM_MAINMENU);
+   Pobject->_classInfo.lpszClassName = "UTClockClass";
+
+   /* Register the window class */
+   #if defined(_Windows) && !defined(BI_PLAT_WIN32) && !defined(__WIN32__) /* Win16? */
+   if (!_HPrevInst) /* We are the first instance of a program? */
+   {
+   #endif /* Win16? */
+   	if (!RegisterClass(&Pobject->_classInfo))
+   	{
+   		MessageBox(NULL, "Cannot register main window class, abandon all hope!", "UTClock - Fatal Error", MB_OK + MB_ICONSTOP + MB_SYSTEMMODAL);
+      	abort();
+   	}
+   #if defined(_Windows) && !defined(BI_PLAT_WIN32) && !defined(__WIN32__) /* Win16? */
+   }
+   #endif /* Win16? */
+
+   /* create a window creation structure to pass to the window proc */
+   cs.lpCreateParams = &Pobject->_classInfo; /* unsure this is correct */
+   cs.hInstance = _HInstance; /* it's us! */
+   cs.hMenu = LoadMenu(_HInstance, MAKEINTRESOURCE(IDM_MAINMENU)); /* load and store the menu */
+   Pobject->_menu = cs.hMenu; /* store the handle in a good place for destrcution later */
+   cs.hwndParent = NULL;
+   cs.cy = Pobject->_height;
+   cs.cx = Pobject->_width;
+   cs.y = Pobject->_top;
+   cs.x = Pobject->_left;
+   cs.style = Pobject->_classInfo.style;
+   cs.lpszName = Pobject->_caption; /* not sure */
+   cs.lpszClass = Pobject->_classInfo.lpszClassName;
+   cs.dwExStyle = 0; /* N/A */
+
+   /* create the window */
+   Pobject->_handle = CreateWindow(Pobject->_classInfo.lpszClassName,
+   							Pobject->_caption,
+                  		WS_BORDER | WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU | WS_THICKFRAME,
+   							Pobject->_left,
+                        Pobject->_top,
+                  		Pobject->_width,
+                        Pobject->_height,
+                  		HWND_DESKTOP,
+                  		NULL, /* the menu is the class's */
+                  		_HInstance,
+                  		&cs);
+	return;
+}
+/*-------------------------------------------------------------------------*/
+void MainWindow_Destruct(S_PMAINWINDOW Pobject)
+{
+	if (Pobject->_handle)
+   {
+   	DestroyWindow(Pobject->_handle);
+      Pobject->_handle = NULL;
+   }
+   if (Pobject->_classInfo.lpszClassName)
+   {
+   	UnregisterClass(Pobject->_classInfo.lpszClassName, _HInstance);
+      Pobject->_classInfo.lpszClassName = NULL;
+   }
+	if (Pobject->_classInfo.hIcon)
+   {
+   	DestroyIcon(Pobject->_classInfo.hIcon);
+      Pobject->_classInfo.hIcon = NULL;
+   }
+   if (Pobject->_menu)
+   {
+   	DestroyMenu(Pobject->_menu);
+      Pobject->_menu = NULL;
+   }
+   if (Pobject->_caption)
+   {
+   	free(Pobject->_caption);
+      Pobject->_caption = 0;
+   }
+	return;
+}
+/*-------------------------------------------------------------------------*/
+HWND MainWindow_GetHandle(void* parent) /* gets the window handle of the window */
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   return s->_handle; /* give handle */
+}
+/*-------------------------------------------------------------------------*/
+const char* MainWindow_GetCaption(void* parent) /* gets the caption of the window */
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   return s->_caption; /* give pointer to caption */
+}
+/*-------------------------------------------------------------------------*/
+const char* MainWindow_SetCaption(void* parent, const char* NewCaption) /* sets the window caption */
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+
+   if (s->_caption) /* already have a caption? */
+   {
+   	free(s->_caption); /* bin it */
+      s->_caption = NULL; /* mark as free */
+   }
+
+   if (NewCaption) /* pointer valid? */
+   {
+   	if (strlen(NewCaption) > 0) /* some text to copy? */
+      {
+      	s->_caption = (char*)malloc(strlen(NewCaption)+1); /* allocate space for new caption */
+         if (s->_caption) /* space allocation successful? */
+         	strcpy(s->_caption, NewCaption); /* copy caption text */
+      }
+   } /* (NewCaption) */
+
+   /* caption copied, now to update the window */
+   SetWindowText(s->GetHandle(s), s->_caption);
+
+   return s->_caption; /* return our buffers address (don't know why) */
+}
+/*-------------------------------------------------------------------------*/
+int MainWindow_GetWidth(void* parent)
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   RECT WindowRect; /* window's rectangular area */
+
+   GetWindowRect(s->GetHandle(s), &WindowRect); /* ask windows for info */
+   s->_width = WindowRect.right - WindowRect.left; /* update object */
+
+   return s->_width; /* give width */
+}
+/*-------------------------------------------------------------------------*/
+int MainWindow_SetWidth(void* parent, int NewWidth) /* Sets width, returns old width */
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   int oldwidth = s->_width; /* save old */
+   s->_width = NewWidth; /* set new */
+
+   /* do window processing if required */
+   if (oldwidth != NewWidth) /* differs? */
+   {
+   	s->UpdateWindowPos(s);
+   }
+
+   return oldwidth; /* give old */
+}
+/*-------------------------------------------------------------------------*/
+int MainWindow_GetHeight(void* parent)
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   RECT WindowRect; /* window's rectangular area */
+
+   GetWindowRect(s->GetHandle(s), &WindowRect); /* ask windows for info */
+   s->_height = WindowRect.bottom - WindowRect.top; /* update object */
+
+   return s->_height; /* give height */
+}
+/*-------------------------------------------------------------------------*/
+int MainWindow_SetHeight(void* parent, int NewHeight) /* sets height, returns old height */
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   int oldheight = s->_height; /* save old */
+   s->_height = NewHeight; /* set new */
+
+   /* do window processing if required */
+   if (oldheight != NewHeight) /* differs? */
+   {
+   	s->UpdateWindowPos(s);
+   }
+
+   return oldheight; /* give old value to caller */
+}
+/*-------------------------------------------------------------------------*/
+int MainWindow_GetTop(void* parent)
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   RECT WindowRect; /* window's rectangular area */
+
+   GetWindowRect(s->GetHandle(s), &WindowRect); /* ask windows for info */
+   s->_top = WindowRect.top; /* update object */
+
+   return s->_top; /* give top */
+}
+/*-------------------------------------------------------------------------*/
+int MainWindow_GetLeft(void* parent)
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   RECT WindowRect; /* window's rectangular area */
+
+   GetWindowRect(s->GetHandle(s), &WindowRect); /* ask windows for info */
+   s->_left = WindowRect.left; /* update object */
+
+   return s->_left; /* give left */
+}
+/*-------------------------------------------------------------------------*/
+int MainWindow_SetTop(void* parent, int NewTop)
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   int oldtop = s->_top; /* save old */
+   s->_top = NewTop; /* set new */
+
+   /* do window processing if required */
+   if (NewTop != oldtop) /* Differs? */
+   {
+   	s->UpdateWindowPos(s);
+   }
+
+   return oldtop; /* give old value */
+}
+/*-------------------------------------------------------------------------*/
+int MainWindow_SetLeft(void* parent, int NewLeft)
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   int oldleft = s->_left; /* save old */
+   s->_left = NewLeft; /* set new */
+
+   /* do window processing if required */
+   if (NewLeft != oldleft) /* differs? */
+   {
+   	s->UpdateWindowPos(s);
+   }
+
+   return oldleft; /* give old value */
+}
+/*-------------------------------------------------------------------------*/
+BOOL MainWindow_IsVisible(void* parent) /* returns _visible */
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   return s->_visible; /* give visibility flag of window */
+}
+/*-------------------------------------------------------------------------*/
+BOOL MainWindow_Show(void* parent) /* shows the window, rets FALSE if already so */
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   if (!s->_visible) /* window hidden? */
+   {
+   	ShowWindow(s->_handle, (s->_reshow) ? SW_SHOW : _nCmdShow); /* show the window (according to the command line sent to WinMain() */
+      UpdateWindow(s->_handle); /* posts us back a paint message */
+      s->_visible = TRUE; /* remember it's shown */
+      s->_reshow = TRUE; /* next will be a reshow */
+      return TRUE; /* success */
+   }
+   return FALSE; /* failure (already shown) */
+}
+/*-------------------------------------------------------------------------*/
+BOOL MainWindow_Hide(void* parent) /* hides the window, rets FALSE if not visible */
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   if (s->_visible) /* window visible? */
+   {
+   	ShowWindow(s->_handle, SW_HIDE); /* hide the window */
+      s->_visible = FALSE; /* remember it's hidden */
+      return TRUE; /* success */
+   }
+   return TRUE; /* success (already hidden) */
+}
+/*-------------------------------------------------------------------------*/
+void MainWindow_Repaint(void* parent)
+{
+	/* maunual repaint of main window */
+
+   /* locals */
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   RECT updateRegion; /* rectangle to draw */
+   HDC hDC; /* Device context */
+   PAINTSTRUCT ps; /* paint information */
+
+	if (GetUpdateRect(s->_handle, &updateRegion, TRUE) == 0) /* want to know where to redraw */
+   {
+   	/* there's nothing to redraw */
+      return; /* don't waste processing time */
+   }
+
+   /* draw region here */
+   hDC = BeginPaint(s->_handle, &ps); /* get a device context */
+
+   MoveToEx(hDC, 0, 0, NULL);
+   LineTo(hDC, s->GetClientWidth(s)-1, 0); /* draw line across top of client area (it separates the menu from the window) */
+
+   EndPaint(s->GetHandle(s), &ps); /* release the device context */
+
+	return; /* done */
+}
+/*-------------------------------------------------------------------------*/
+void MainWindow_UpdateWindowPos(void* parent)
+{
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+	MoveWindow(s->GetHandle(s), s->GetLeft(s), s->GetTop(s), s->GetWidth(s), s->GetHeight(s), TRUE);
+}
+/*-------------------------------------------------------------------------*/
+int MainWindow_GetClientWidth(void* parent)
+{
+	/* locals */
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   RECT wr; /* Window's rect area */
+
+   GetClientRect(s->GetHandle(s), &wr); /* ask windows */
+   s->_clientWidth = wr.right; /* right was assigned a width by windows, it's not really a right */
+
+   return s->_clientWidth; /* give to caller */
+}
+/*-------------------------------------------------------------------------*/
+int MainWindow_GetClientHeight(void* parent)
+{
+	/* locals */
+	S_PMAINWINDOW s = (S_MAINWINDOW*)parent; /* convert pointer */
+   RECT wr; /* Window's rect area */
+
+   GetClientRect(s->GetHandle(s), &wr); /* ask windows */
+   s->_clientHeight = wr.bottom; /* bottom was assigned a height by Windows, it's not what it says it is at all */
+
+   return s->_clientHeight; /* give to caller */
+}
+/*-------------------------------------------------------------------------*/
+#pragma argsused /* stop parameter not used warning */
+void MainWindow_RestrictSize(void* parent, MINMAXINFO FAR* PMinMaxInfo)
+{
+	/* locals */
+	RECT DesktopWindowRect;
+
+	/* stop the window being over-minimized (keep it reasonable) */
+	PMinMaxInfo->ptMinTrackSize.x = 250;
+   PMinMaxInfo->ptMinTrackSize.y = 100;
+   /* Stop oversize, remember that a small clock should not fill the entire screen */
+   PMinMaxInfo->ptMaxTrackSize.x = 375;
+   PMinMaxInfo->ptMaxTrackSize.y = 250;
+   /* If the user really tries to maximize this small clock, let it fill half the screen */
+   GetWindowRect(GetDesktopWindow(), &DesktopWindowRect); /* get desktop dimensions */
+   PMinMaxInfo->ptMaxSize.y = (DesktopWindowRect.bottom-1) /2;
+   PMinMaxInfo->ptMaxSize.x = (DesktopWindowRect.right-1) /2;
+	return; /* message has been processed */
+
+   /* We did not need to know the parent window, but we had it
+   sent to use to keep convention with all the other member
+   functions */
+}
+/*-------------------------------------------------------------------------*/
+LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+	/* Windowing procedure for this window */
+   switch (msg)
+   {
+   	case WM_CLOSE : /* close the window */
+      {
+         MainWindow_Destruct(&MainWindow); /* destroy app object, this calls DestroyWindow() */
+      	break;
+      }
+      case WM_DESTROY : /* window is being destroyed */
+      {
+      	PostQuitMessage(0); /* want to stop message loop now */
+         break;
+      }
+      case WM_GETMINMAXINFO : /* Forced min/max sizes */
+      {
+      	MainWindow.RestrictSize(&MainWindow, (MINMAXINFO FAR*)lParam);
+      	break; /* message has been processed */
+      }
+      case WM_COMMAND : /* a menu message? */
+      {
+      	switch (wParam) /* switch on menu item */
+         {
+            case CM_WINDOW_EXIT : /* request to close */
+            {
+            	BYTE msgrec; /* message not recieved yet */
+               do
+               {
+               	msgrec = (BYTE)PostMessage(MainWindow.GetHandle(&MainWindow), WM_CLOSE, 0, 0L); /* request to close main window */
+               } while (!msgrec); /* persist until message is recieved */
+
+               break; /* end of menuitem */
+            }
+            case CM_WINDOW_REPAINT : /* request to repaint? */
+      		{
+      			UpdateWindow(MainWindow.GetHandle(&MainWindow)); /* force paint of window */
+         		break; /* end of menuitem */
+      		}
+            default : /* oops! */
+            {
+            	MessageBox(MainWindow.GetHandle(&MainWindow), "Invalid menu item", NULL, MB_OK);
+            }
+         }
+         break; /* end of message */
+      }
+      case WM_PAINT : /* window needs repainting? */
+      {
+      	MainWindow.Repaint(&MainWindow); /* window specific painting */
+         return DefWindowProc(hwnd, msg, wParam, lParam); /* do windows window repaint also */
+      }
+   	default : /* not a message I wish to process */
+      {
+      	/* call default processor */
+      	return DefWindowProc(hwnd, msg, wParam, lParam);
+      }
+   } /* end of message switch */
+
+   return 0; /* Processed given message */
+}
+/*-------------------------------------------------------------------------*/
+#include <Windows.H>
+#include <StdLib.H>
+#pragma hdrstop
+
+#include "MainWin.H" /* main window */
+#include "UTClock.H" /* ours */
+#include "Glbls.H"
+/*-------------------------------------------------------------------------*/
+#pragma argsused
+int PASCAL WinMain(HINSTANCE HInstance, HINSTANCE HPrevInstance, LPSTR lpCmdLine, int nCmdShow)
+{
+	/* locals */
+   MSG msg; /* message structure for main message loop */
+
+	/* init */
+	_HInstance = HInstance; /* store handle globally */
+   _nCmdShow = nCmdShow; /* store window show paramater globally */
+   #if defined(_Windows) && !defined(BI_PLAT_WIN32) && !defined(__WIN32__)
+   _HPrevInst = HPrevInstance; /* store handle globally (Win16 only) */
+   #endif
+
+   CClassGlobalConstruct(); /* constrcut global C classes */
+   atexit(CClassGlobalDestruct); /* post global C class destructor */
+
+   MainWindow.Show(&MainWindow); /* show the main window */
+
+   /* the main message loop */
+   while (GetMessage(&msg, (HWND)NULL, 0, 0))
+   {
+      DispatchMessage(&msg);
+   }
+
+	return msg.wParam; /* terminate program normally */
+}
+/*-------------------------------------------------------------------------*/
+NAME UtClock
+DESCRIPTION 'Universal Time Stamp Clock Display (C) 1998, DDRP @ Daybo Logic.'
+EXPORTS
+	MainWndProc
+/****************************************************************************
+
+
+utclock.rc
+
+produced by Borland Resource Workshop
+
+
+*****************************************************************************/
+
+#include "UTClock.RH"
+
+VERSIONINFO_1 VERSIONINFO
+FILEVERSION 1, 0, 0, 0
+PRODUCTVERSION 1, 0, 0, 0
+FILEOS VOS_NT_WINDOWS32
+FILETYPE VFT_APP
+{
+ BLOCK "StringFileInfo"
+ {
+  BLOCK "040904E4"
+  {
+   VALUE "CompanyName", "Daybo Logic\000\000"
+   VALUE "FileDescription", "Universal Time Stamp Display Clock\000"
+   VALUE "FileVersion", "1.00\000\000"
+   VALUE "InternalName", "UtClock\000"
+   VALUE "LegalCopyright", "Daybo Logic 1998\000\000"
+   VALUE "OriginalFilename", "UtClock.EXE\000"
+   VALUE "Programmer", "David Duncan Ross Palmer\000\000"
+   VALUE "BuildTool", "Borland C++ 5.02\000"
+  }
+
+ }
+
+ BLOCK "VarFileInfo"
+ {
+  VALUE "Translation", 0x409, 1252
+ }
+
+}
+
+
+IDI_CLOCK			ICON			"C:\Windows\Icons\Clock.ico"
+
+IDM_MAINMENU MENU 
+{
+ POPUP "&Window"
+ {
+  MENUITEM "&Repaint", CM_WINDOW_REPAINT
+  MENUITEM "E&xit", CM_WINDOW_EXIT
+ }
+
+ POPUP "&Help"
+ {
+  MENUITEM "&About", CM_HELP_ABOUT
+ }
+
+}
+
+STRINGTABLE
+{
+ CM_WINDOW_REPAINT, "Manually repaints the window"
+ CM_WINDOW_EXIT, "Exits the clock"
+}