/*---------------------------------------
WAKEUP.C -- Alarm Clock Program
(c) Charles Petzold, 1998
---------------------------------------*/
#include <windows.h>
#include <commctrl.h> //包含通用控件头文件
// ID values for 3 child windows三个子窗口ID
#define ID_TIMEPICK 0 //时间控件ID
#define ID_CHECKBOX 1 //核取方块ID
#define ID_PUSHBTN 2 //关闭响铃按钮ID
// Timer ID计时器ID
#define ID_TIMER 1
//数量
#define FTTICKSPERHOUR (60 * 60 * (LONGLONG) 10000000)
// Defines and structure for waveform "file" 定义音频流结构文件
#define SAMPRATE 11025 //取样频率
#define NUMSAMPS (3 * SAMPRATE) //取样的数量
#define HALFSAMPS (NUMSAMPS / 2) //取样数量的一半
typedef struct
{
char chRiff[4] ;
DWORD dwRiffSize ;
char chWave[4] ;
char chFmt [4] ;
DWORD dwFmtSize ;
PCMWAVEFORMAT pwf ;
char chData[4] ;
DWORD dwDataSize ;
BYTE byData[0] ;
}
WAVEFORM ; //定义一个音频流结构体
// The window proc and the subclass proc主窗口过程与子窗口类过程函数
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; //主窗口过程函数
LRESULT CALLBACK SubProc (HWND, UINT, WPARAM, LPARAM) ; //子窗口类过程函数
// Original window procedure addresses for the subclassed windows储存原子窗口过程函数数组
WNDPROC SubbedProc [3] ;
// The current child window with the input focus 具有输入焦点的当前子窗口
HWND hwndFocus ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, //主函数
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName [] = TEXT ("WakeUp") ;
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = 0 ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) (1 + COLOR_BTNFACE) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow (szAppName, szAppName,
WS_OVERLAPPED | WS_CAP