Awake, written by Jason M. Chu of Boston University, is an MFC time application that demonstrate the basic use of time and date functions. Features includes a digital clock, a calendar, and an alarm clock function.
The dialog-based application was developed entirely in Microsoft Visual C++. Awake requires Windows NT 4.0 or later (Windows 98 or later is recommended). The application was first developed in the Microsoft Visual Studio 6.0 environment and was later imported to Microsoft Visual Studio .NET.
The main window contains one tab control object with three tab items: the Time tab, the Calendar tab, and the Options tab. The CTabCtrl class was used for tab control implementation. Conditions were added to the OnSysCommand function so that the application dialog will not be closed with the 'Enter' or 'Esc' keys.
The system time may be retrieved by using the time() function from <time.h>, in which the time will be in the format of a long integer. There are two ways to derive the actually time from the returned value of the time() function.
One way is through numerical computation. The long integer time value represents the total number of seconds passed since midnight of 1/1/1970. The correct time may be calculated by using a combinations of division, modulus, and addition/subtraction. Time zone hour difference adjustments may be needed.
The second way, which is the one implemented in Awake, is to construct a new CTime object using the returned value of the time() function as the construction parameter. The current time may be obtained from the CTime class member functions GetHour(), GetMinute(), and GetSecond().
The system time is displayed in the form of a digital clock.
The CTime class may also provide the date with the member functions GetYear(), GetMonth(), GetDay(), and GetDayOfWeek(). The COleDateTime class was used for calendar control. Date adjustments will not be needed unless there's a change in date, such as when the application is left running overnight.
The calendar is in the form of a monthly calendar.
The Options tab contains settings for clock display and alarm properties.
When the system time is in match with the alarm clock time preset by the user, an alert dialog will be displayed. In addition, the PlaySound macro (wimmm.lib) will be used to provide an audio alarm, which is an imported WAV file. The alert dialog will initially start a thread that plays the audio alarm repeatedly. The thread will end when the dialog is closed.