中国计算机的发展:怎样在vc++编的钟表上加入闹钟的功能?

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 01:12:10
设置一个窗口,
输入闹钟定时的时间,
到时可以响音乐.

CTime nowtime=CTime::GetCurrentTime();
CString c_hour=nowtime.Format(_T("%h"));
CString c_miniter=nowtime.Format(_T("%m"));
....

SetTimer(1,1000,NULL);

#include <MMSystem.h>
#pragma comment(lib, "winmm.lib")

OnTimer(...)
{

if(strcmp("YourHour",c_hour)==0 &&strcmp("YourMiniter",c_miniter)==0)
{
PlaySound((LPCSTR)IDR_WAVE1,AfxGetResourceHandle(),SND_RESOURCE|SND_ASYNC|SND_NODEFAULT );
//播放资源里的声音文件

}
}