www.pudn.com > speech1.rar > SpecchDlg.cpp


// SpecchDlg.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "Specch.h" 
#include "SpecchDlg.h" 
#include "DlgProxy.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CAboutDlg dialog used for App About 
 
class CAboutDlg : public CDialog 
{ 
public: 
	CAboutDlg(); 
 
// Dialog Data 
	//{{AFX_DATA(CAboutDlg) 
	enum { IDD = IDD_ABOUTBOX }; 
	//}}AFX_DATA 
 
	// ClassWizard generated virtual function overrides 
	//{{AFX_VIRTUAL(CAboutDlg) 
	protected: 
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support 
	//}}AFX_VIRTUAL 
 
// Implementation 
protected: 
	//{{AFX_MSG(CAboutDlg) 
	//}}AFX_MSG 
	DECLARE_MESSAGE_MAP() 
}; 
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 
{ 
	//{{AFX_DATA_INIT(CAboutDlg) 
	//}}AFX_DATA_INIT 
} 
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CAboutDlg) 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 
	//{{AFX_MSG_MAP(CAboutDlg) 
		// No message handlers 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSpecchDlg dialog 
 
IMPLEMENT_DYNAMIC(CSpecchDlg, CDialog); 
 
CSpecchDlg::CSpecchDlg(CWnd* pParent /*=NULL*/) 
	: CDialog(CSpecchDlg::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(CSpecchDlg) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 
	m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON1); 
	m_pAutoProxy = NULL; 
 
	// 得到该软件的路径,在OnInitDialog()中要向注册表写入 
	GetModuleFileName(NULL , (char*)(LPCTSTR)m_fileName , MAX_PATH); 
	m_fileName = (CString)m_fileName; 
 
	// 以下初始化成员变量 
	for (int i = 0 ; i < 3 ; i++) 
	{ 
		m_warnType[i] = 0 ;         // 提示类型 
		m_speakType[i] = 0 ;		// 发音人物 
		m_musicPath[i] = "曾经有一份.WAV" ;			// 默认音乐路径 
		// 默认语音的文本内容 
		m_strSpeakContent[i] = "It's time for doing something." ;  
		m_strWarnType[i] = "气泡提示" ;    // 默认为气泡提示 
	} 
 
	for (i = 0 ; i < 7 ; i++)  
	{ 
		m_whichDayAlarm[i] = 0 ;      // 默认每天都不播报 
		m_strWhichDayAlarm[i] = "" ; 
	} 
	m_alarmHour = 8 ; 
	m_alarmMinute = 30 ; 
	m_bFind = FALSE ; 
	m_rate = 0 ;		// 默认语速 
	m_volume = 50 ;		// 默认音量 
	ReadFileData() ;     // 从文件当中读取资料 
} 
 
CSpecchDlg::~CSpecchDlg() 
{ 
	// If there is an automation proxy for this dialog, set 
	//  its back pointer to this dialog to NULL, so it knows 
	//  the dialog has been deleted. 
	if (m_pAutoProxy != NULL) 
		m_pAutoProxy->m_pDialog = NULL; 
} 
 
void CSpecchDlg::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CSpecchDlg) 
	DDX_Control(pDX, IDC_HOLIDAYLIST, m_holidayList); 
	DDX_Control(pDX, IDC_WORKLIST, m_list); 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CSpecchDlg, CDialog) 
	//{{AFX_MSG_MAP(CSpecchDlg) 
	ON_WM_SYSCOMMAND() 
	ON_MESSAGE(WM_TRAY , OnShowTask) 
	ON_WM_PAINT() 
	ON_WM_QUERYDRAGICON() 
	ON_WM_CLOSE() 
	ON_COMMAND(IDM_MAIN, OnMain) 
	ON_COMMAND(IDM_SUPPORT, OnSupport) 
	ON_COMMAND(IDM_EXIT, OnExit) 
	ON_WM_TIMER() 
	ON_NOTIFY(NM_RCLICK, IDC_WORKLIST, OnRclickWorklist) 
	ON_NOTIFY(NM_RCLICK, IDC_HOLIDAYLIST, OnRclickHolidaylist) 
	ON_COMMAND(IDM_INFOCHANGE, OnInfochange) 
	ON_NOTIFY(MCN_GETDAYSTATE, IDC_MONTHCALENDAR1, OnGetdaystateMonthcalendar1) 
	ON_BN_CLICKED(IDB_SOUNDSET, OnSoundset) 
	ON_BN_CLICKED(IDB_ALARM, OnAlarm) 
	ON_BN_CLICKED(IDB_WORKSET, OnWorkset) 
	ON_BN_CLICKED(IDB_HOLIDAYSET, OnHolidayset) 
	ON_BN_CLICKED(IDB_VIEWWORK, OnViewwork) 
	ON_COMMAND(IDM_INFOADD, OnInfoadd) 
	ON_COMMAND(IDM_ABOUT, OnAbout) 
	ON_COMMAND(IDM_DEL, OnDel) 
	ON_WM_DESTROY() 
	ON_NOTIFY(MCN_SELECT, IDC_MONTHCALENDAR1, OnSelectMonthcalendar1) 
	ON_BN_CLICKED(IDB_HIDE, OnHide) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSpecchDlg message handlers 
 
BOOL CSpecchDlg::OnInitDialog() 
{ 
	CDialog::OnInitDialog(); 
 
	// Add "About..." menu item to system menu. 
 
	// IDM_ABOUTBOX must be in the system command range. 
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); 
	ASSERT(IDM_ABOUTBOX < 0xF000); 
 
	CMenu* pSysMenu = GetSystemMenu(FALSE); 
	if (pSysMenu != NULL) 
	{ 
		CString strAboutMenu; 
		strAboutMenu.LoadString(IDS_ABOUTBOX); 
		if (!strAboutMenu.IsEmpty()) 
		{ 
			pSysMenu->AppendMenu(MF_SEPARATOR); 
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); 
		} 
	} 
 
	// Set the icon for this dialog.  The framework does this automatically 
	//  when the application's main window is not a dialog 
	SetIcon(m_hIcon, TRUE);			// Set big icon 
	SetIcon(m_hIcon, FALSE);		// Set small icon 
	// TODO: Add extra initialization here 
 
	// 开机自动运行的设置 
	HKEY hKey ; 
	LPCTSTR data_Set="Software\\Microsoft\\Windows\\CurrentVersion\\Run" ; 
	//设置注册表中相关的路径 
	long ret0=::RegOpenKeyEx(HKEY_LOCAL_MACHINE , data_Set , 0 , KEY_WRITE , &hKey) ; 
	//打开注册表中的相应项 
	if(ret0 != ERROR_SUCCESS) 
	{ 
		MessageBox("打开注册表时出现错误!"); 
	} 
	 
	int length = m_fileName.GetLength(); 
	LPBYTE lpb = new BYTE[length+1]; 
	for(int i= 0;i < length ; i++) 
	{ 
		lpb[i] = m_fileName[i]; 
	} 
	lpb[length]=0; 
 
	long ret1 = ::RegSetValueEx(hKey ,"Test" , NULL , REG_SZ , lpb , length+1); 
	//将相关的信息写入注册表 
	if(ret1 != ERROR_SUCCESS) 
	{ 
		MessageBox("写注册表时出现错误!") ; 
	} 
	delete lpb ; 
	::RegCloseKey(hKey) ; 
	//关闭注册表中的相应的项 
	 
	m_isShow = false ;       // 检查窗口是否被最小化到托盘 
	GetLocalTime(&m_sysTime) ;		// 得到系统时间 
	m_time = CTime::GetCurrentTime() ;// 得到系统的时间 
	CString Str ; 
 
	// 创建日历表并设置日历表的属性 
	m_monthCalCtrl = (CMonthCalCtrl*)GetDlgItem(IDC_MONTHCALENDAR1) ; 
	m_monthCalCtrl->SetCurSel((COleDateTime)m_sysTime) ; 
	m_monthCalCtrl->SetMonthDelta(1) ; 
	m_monthCalCtrl->SetColor(MCSC_BACKGROUND | MCSC_TITLEBK  , RGB(241 , 212 , 54)) ; 
	m_monthCalCtrl->SetColor(MCSC_MONTHBK , RGB(247 ,242 , 242)) ; 
 
	// 创建工作备忘表格和自定义节假日表格 
	m_imagelist.Create(16,16,TRUE,2,2); 
	m_imagelist.Add(AfxGetApp()->LoadIcon(IDI_ICON2));  // 向表格中加入图标 
	m_list.SetImageList(&m_imagelist,LVSIL_SMALL); 
	m_holidayList.SetImageList(&m_imagelist , LVSIL_SMALL) ; 
 
	m_font.CreateFont(16, 0,0,0,FW_NORMAL, 0,0,0, 
		DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, 
		DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial"); 
	m_list.SetFont(&m_font);		// 设置工作备忘表格的字体 
	m_holidayList.SetFont(&m_font) ;	// 设置节假日表格的字体 
 
	m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); 
	m_list.SetBkColor(RGB(247,247,255)); 
	m_list.SetTextColor(RGB(0,0,255)); 
	m_list.SetTextBkColor(RGB(247,247,255)); 
	m_list.InsertColumn(0, "     时间", LVCFMT_LEFT, 70); 
	m_list.InsertColumn(1, "          工作备忘", LVCFMT_LEFT, 500); 
	 
	m_holidayList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES) ; 
	m_holidayList.SetBkColor(RGB(247,247,255)); 
	m_holidayList.SetTextColor(RGB(0,0,255)); 
	m_holidayList.SetTextBkColor(RGB(247,247,255)); 
	m_holidayList.InsertColumn(0 , "     时间" , LVCFMT_LEFT , 70) ; 
	m_holidayList.InsertColumn(1 , "         假日内容" , LVCFMT_LEFT , 300) ; 
 
	// 初始化两个链表的位置,下面将要用到。防止位置为NULL 
	m_workTimePos = m_timeList.GetHeadPosition() ; 
	m_strWorkPos = m_strWorkList.GetHeadPosition() ; 
 
	ShowWorkList() ;		// 在主窗口中显示当天的工作备忘 
 	ShowHolidayList() ;		// 在主窗口中显示所有的节假日 
 
	// 初始化成员变量,为该软件加入语音功能 
	CLSIDFromProgID(L"SAPI.SpVoice", &CLSID_SpVoice); 
	voice[0].CreateDispatch(CLSID_SpVoice); 
	voice[1].CreateDispatch(CLSID_SpVoice) ; 
	voice[2].CreateDispatch(CLSID_SpVoice) ; 
	 
	pDisp[0] = voice[0].m_lpDispatch; 
	pDisp[1] = voice[1].m_lpDispatch ; 
	pDisp[2] = voice[2].m_lpDispatch ; 
 
	HRESULT hr[3] ; 
	hr[0] = pDisp[0]->QueryInterface(CLSID_SpVoice , (void**)&voice[0].m_lpDispatch) ; 
	hr[1] = pDisp[1]->QueryInterface(CLSID_SpVoice , (void**)&voice[1].m_lpDispatch) ; 
	hr[2] = pDisp[2]->QueryInterface(CLSID_SpVoice , (void**)&voice[2].m_lpDispatch) ; 
 
	for(i = 0 ; i < 3 ; i++) 
	{ 
		if(hr[i] == S_OK) 
		{ 
			pDisp[i]->Release() ; 
		} 
		else 
		{ 
			voice[i].AttachDispatch(pDisp[i] , TRUE) ; 
		} 
		voice[i].SetRate(m_rate) ; 
		voice[i].SetVolume(m_volume) ; 
	} 
	 
	// 向窗口发送消息,使其一运行时就最小化到托盘区 
   	PostMessage(WM_SYSCOMMAND,SC_MINIMIZE,FALSE); 
	 
	// 以下是对主窗口最小化到托盘区的结构体NOTIFYICONDATA的设置 
	tnd.cbSize = sizeof(NOTIFYICONDATA) ; 
	tnd.hWnd = GetSafeHwnd() ; 
	tnd.uFlags=NIF_MESSAGE | NIF_ICON | NIF_INFO | NIF_TIP ; 
	tnd.uCallbackMessage=WM_TRAY ; 
	tnd.uID = IDI_ICON1 ; 
	tnd.hIcon = AfxGetApp()->LoadIcon(IDI_ICON1) ; 
	tnd.dwInfoFlags = NIIF_INFO ; 
	strcpy(tnd.szTip,"闹钟小软件") ;	// 鼠标移到我们的图标时显示的内容 
	_tcscpy(tnd.szInfoTitle , "闹钟小软件") ;  
	_tcscpy(tnd.szInfo , "欢迎使用") ; // 程序一运行时在托盘区冒出个气泡通知用户 
    Shell_NotifyIcon(NIM_ADD,&tnd) ;  
 
	SetTimer(5 , 1000 * 60 , NULL) ;	// 时间回调函数,这里设置为1分钟回调一次 
 
	return TRUE;  // return TRUE  unless you set the focus to a control 
} 
 
void CSpecchDlg::OnSysCommand(UINT nID, LPARAM lParam) 
{ 
	if ((nID & 0xFFF0) == IDM_ABOUTBOX) 
	{ 
		CAboutDlg dlgAbout; 
		dlgAbout.DoModal(); 
	} 
	if(nID == SC_MAXIMIZE) 
	{ 
		return ; 
	} 
	if(nID == SC_MINIMIZE) 
	{ 
		m_isShow = false ;	// 窗口被最小化到托盘时改变成员变量的值 
		ShowWindow(SW_HIDE) ;	// 隐藏窗口 
	}	 
	else 
	{ 
		CDialog::OnSysCommand(nID, lParam); 
		WriteFileData() ;	// 当关闭窗口时向指定的文件写入数据 
	} 
} 
 
// If you add a minimize button to your dialog, you will need the code below 
//  to draw the icon.  For MFC applications using the document/view model, 
//  this is automatically done for you by the framework. 
 
void CSpecchDlg::OnPaint()  
{ 
	if (IsIconic()) 
	{ 
		CPaintDC dc(this); // device context for painting 
 
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); 
 
		// Center icon in client rectangle 
		int cxIcon = GetSystemMetrics(SM_CXICON); 
		int cyIcon = GetSystemMetrics(SM_CYICON); 
		CRect rect; 
		GetClientRect(&rect); 
		int x = (rect.Width() - cxIcon + 1) / 2; 
		int y = (rect.Height() - cyIcon + 1) / 2; 
 
		// Draw the icon 
		dc.DrawIcon(x, y, m_hIcon); 
	} 
	else 
	{ 
		CDialog::OnPaint(); 
	} 
} 
 
// The system calls this to obtain the cursor to display while the user drags 
//  the minimized window. 
HCURSOR CSpecchDlg::OnQueryDragIcon() 
{ 
	return (HCURSOR) m_hIcon; 
} 
 
// Automation servers should not exit when a user closes the UI 
//  if a controller still holds on to one of its objects.  These 
//  message handlers make sure that if the proxy is still in use, 
//  then the UI is hidden but the dialog remains around if it 
//  is dismissed. 
 
void CSpecchDlg::OnClose()  
{ 
	if (CanExit()) 
		CDialog::OnClose(); 
} 
 
void CSpecchDlg::OnOK()  
{ 
	if (CanExit()) 
		CDialog::OnOK(); 
} 
 
void CSpecchDlg::OnCancel()  
{ 
	if (CanExit()) 
		CDialog::OnCancel(); 
} 
 
BOOL CSpecchDlg::CanExit() 
{ 
	// If the proxy object is still around, then the automation 
	//  controller is still holding on to this application.  Leave 
	//  the dialog around, but hide its UI. 
	if (m_pAutoProxy != NULL) 
	{ 
		ShowWindow(SW_HIDE); 
		return FALSE; 
	} 
	return TRUE; 
} 
 
// 该函数用来控制窗口由中心向四面展开 
void CSpecchDlg::Display() 
{ 
	CRect dlgRect;  
	GetWindowRect(dlgRect);  
	CRect desktopRect;  
	GetDesktopWindow()->GetWindowRect(desktopRect); 
	MoveWindow((desktopRect.Width() - dlgRect.Width()) / 2 ,  
		(desktopRect.Height() - dlgRect.Height()) / 2 , 0 , 0);  
	nWidth=dlgRect.Width();  
	nHeight=dlgRect.Height();  
	dx=2; 
	dy=4;  
	dx1=2; 
	dy1=2; 
	SetTimer(1,10 , NULL);  
} 
 
// 托盘右键菜单项 主窗口 的响应函数 
void CSpecchDlg::OnMain()  
{ 
	// TODO: Add your command handler code here 
	//显示程序主框架  
	ModifyStyle(WS_POPUP,WS_OVERLAPPEDWINDOW);   
	ModifyStyleEx(WS_EX_TOOLWINDOW,WS_EX_TOPMOST);  
	ShowWindow(SW_SHOWNORMAL);  
	Display() ;		// 展开窗口 
} 
 
// 托盘右键菜单项 技术支持的响应函数 
void CSpecchDlg::OnSupport()  
{ 
	// TODO: Add your command handler code here 
	CAboutDlg dlg ; 
	dlg.DoModal() ; 
} 
 
void CSpecchDlg::OnExit()  
{ 
	// TODO: Add your command handler code here 
	WriteFileData() ;	//	退出程序时向指定的文件中写入数据 
	//退出程序之前用NIM_DELETE属性指定删除掉加入到托盘的图标  
	tnd.cbSize=sizeof(NOTIFYICONDATA);  
	tnd.hWnd=this->m_hWnd;  
	tnd.uID=IDI_ICON1;	// 保证删除的是我们的图标  
	Shell_NotifyIcon(NIM_DELETE,&tnd);  
	AfxPostQuitMessage(0); 		// 退出程序 	 
} 
 
// 自定义消息的响应函数 
void CSpecchDlg::OnShowTask(WPARAM wParam , LPARAM lParam) 
{ 
	UINT uId = (UINT) wParam ; 
	UINT uMouseMsg = (UINT) lParam ; 
	CMenu menu ; 
	CMenu *pMenu ; 
	POINT pt ; 
	if(uMouseMsg == WM_RBUTTONDOWN)	// 如果是单击右键  
	{  
		switch(uId)  
		{  
		case IDI_ICON1:		// 如果是我们的图标  
			GetCursorPos(&pt) ;		// 取得鼠标位置并执行以下相应的操作 
			menu.LoadMenu(IDM_TRAY); // 载入菜单 
			pMenu=menu.GetSubMenu(0);  
			ASSERT(pMenu!=0);  
			pMenu->TrackPopupMenu (0,pt.x,pt.y,this) ;  
		break;  
		default:  
		break;  
		} 
	} 
	if(uMouseMsg == WM_LBUTTONDBLCLK)	// 如果是左键双击  
	{  
		switch(uId)  
		{  
		case IDI_ICON1:  
			if(m_isShow==false)  
			{  
				//显示主窗口  
				ModifyStyle(WS_POPUP,WS_OVERLAPPEDWINDOW);   
				ModifyStyleEx(WS_EX_TOOLWINDOW,WS_EX_TOPMOST);  
				Display() ;		// 展开窗口 
				ShowWindow(SW_SHOWNORMAL); // 将窗口正常显示 
				m_isShow = true; // 改变成员变量窗口是否被显示的值 
			}  
			else  
			{  
				ShowWindow(SW_HIDE); //隐藏主窗口  
				ModifyStyle(WS_CAPTION|FWS_PREFIXTITLE|WS_SYSMENU| WS_MINIMIZEBOX|WS_MAXIMIZEBOX,WS_POPUP);  
				ModifyStyleEx(WS_EX_TOPMOST,WS_EX_TOOLWINDOW);  
				m_isShow = false; // 改变成员变量窗口是否被显示的值 
			}  
		break;  
		default:  
		break;  
		} 
	} 
} 
 
// 时间回调函数 
void CSpecchDlg::OnTimer(UINT nIDEvent)  
{ 
	// TODO: Add your message handler code here and/or call default 
	CRect dlgRect ; 
	GetWindowRect(dlgRect) ; 
 
	CRect desktopRect ; 
	GetDesktopWindow()->GetWindowRect(desktopRect) ; 
	 
	if(nIDEvent == 1) 
	{ 
		MoveWindow( 
		(-dx+desktopRect.Width() - dlgRect.Width()) / 2 , 
		(-dy+desktopRect.Height() - dlgRect.Height()) / 2 ,  
		+dx+dlgRect.Width(), +dy+dlgRect.Height()); 
 
		if(dlgRect.Width() >=nWidth)  
		dx=0; // 不再横向扩展窗口 
		if(dlgRect.Height() >=nHeight) 
		dy=0; // 不再纵向扩展窗口 
		if((dlgRect.Width() >=nWidth) && (dlgRect.Height() >=nHeight)) 
		KillTimer(1); //Stop the timer 
	} 
 
	if((dlgRect.Width() >=nWidth) && (dlgRect.Height() >=nHeight)) 
		KillTimer(1); //Stop the timer 
 
	if(nIDEvent == 2) 
	{ 
		MoveWindow((+dx+desktopRect.Width() - dlgRect.Width()) / 2, 
		(+dy+desktopRect.Height() - dlgRect.Height()) / 2, 
		-dx1+dlgRect.Width(), 
		-dy1+dlgRect.Height() ); 
 
		if(dlgRect.Width() <= 0)  
			dx1=0; // 不再横向扩展窗口 
		if(dlgRect.Height() <= 0 ) 
			dy1=0; // 不再纵向扩展窗口 
		if((dlgRect.Width() <= 0 ) && (dlgRect.Height() <=0)) 
		{ 
			KillTimer(2); //Stop the timer 
		} 
	}	 
	if(nIDEvent == 5) 
	{ 
		IsTimeUp() ;	// 判断是否时间到了该做出响应 
		KillTimer(5) ; 
		SetTimer(5 , 1000 * 60 , NULL) ; 
	} 
	CDialog::OnTimer(nIDEvent);	 
} 
 
// 鼠标点击工作备忘表格的响应函数 
void CSpecchDlg::OnRclickWorklist(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	// TODO: Add your control notification handler code here 
	CPoint pt ; 
	::GetCursorPos(&pt) ;	// 得到当前鼠标的位置 
 
	m_listIndex = 0 ;		// 记录鼠标点击的是哪个表格 
	CMenu menu ; 
	menu.LoadMenu(IDM_MENU1) ;	// 载入菜单 
	CMenu *pMenu = menu.GetSubMenu(0) ; 
	pMenu->TrackPopupMenu(TPM_RIGHTBUTTON , pt.x , pt.y , this , NULL) ;	 
	*pResult = 0; 
} 
 
// 鼠标点击节假日表格的响应函数 
void CSpecchDlg::OnRclickHolidaylist(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	// TODO: Add your control notification handler code here 
	CPoint pt ; 
	::GetCursorPos(&pt) ;	// 得到当前鼠标的位置 
 
	m_listIndex = 1 ;		// 记录鼠标点击的是哪个表格 
	CMenu menu ; 
	menu.LoadMenu(IDM_MENU1) ;	// 载入菜单 
	CMenu *pMenu = menu.GetSubMenu(0) ;	 
	pMenu->TrackPopupMenu(TPM_RIGHTBUTTON , pt.x , pt.y , this , NULL) ;	 
	*pResult = 0; 
} 
 
// 右键菜单 资料修改选项的响应函数 
void CSpecchDlg::OnInfochange()  
{ 
	// TODO: Add your command handler code here 
	if(m_listIndex == 0)	//	点击的是工作备忘表格 
	{ 
		POSITION Pos = m_list.GetFirstSelectedItemPosition() ; 
		m_nIndex = m_list.GetNextSelectedItem(Pos) ;       // 得到项目索引 
 
		if(m_nIndex == -1) 
		{ 
			MessageBox("请选择一项再修改!","提示",MB_ICONINFORMATION); 
			return ; 
		} 
 
		pos = m_timeList.GetHeadPosition() ; 
		workPos = m_strWorkList.GetHeadPosition() ; 
 
		for ( ; pos != NULL && (m_timeList.GetAt(pos).GetYear() != m_time.GetYear() 
			|| m_timeList.GetAt(pos).GetMonth() != m_time.GetMonth() || 
			m_timeList.GetAt(pos).GetDay() != m_time.GetDay()) ; m_timeList.GetNext(pos))  
		{ 
			m_strWorkList.GetNext(workPos) ; 
		} 
 
		for (int n = 0 ; n < m_nIndex ; n++)  
		{ 
			m_timeList.GetNext(pos) ; 
			m_strWorkList.GetNext(workPos) ; 
		} 
		CWorkChangeDlg ed ; 
		// 向工作备忘编辑框传送数据 
		ed.SetYear(m_timeList.GetAt(pos).GetYear()) ; 
		ed.SetMonth(m_timeList.GetAt(pos).GetMonth()) ; 
		ed.SetDay(m_timeList.GetAt(pos).GetDay()) ; 
		ed.SetHour(m_timeList.GetAt(pos).GetHour()) ; 
		ed.SetMinute(m_timeList.GetAt(pos).GetMinute()) ; 
		ed.m_strWorkInfo = m_strWorkList.GetAt(workPos) ; 
 
		if(m_timeList.GetAt(m_workTimePos) >= m_timeList.GetAt(pos)) 
		{ 
			m_bFind = false ; 
		} 
		if(ed.DoModal() == IDOK) 
		{ 
//			m_bFind = false ; 
			m_timeList.RemoveAt(pos) ; 
			m_strWorkList.RemoveAt(workPos) ; 
 
			ShowWorkList(ed) ; 
//			m_bFind = TRUE ; 
		} 
	} 
	if(m_listIndex == 1) 
	{ 
		POSITION Pos = m_holidayList.GetFirstSelectedItemPosition() ; 
		m_nIndex = m_holidayList.GetNextSelectedItem(Pos) ;       // 得到下一个索引 
		 
		if(m_nIndex == -1) 
		{ 
			MessageBox("请选择一项再修改!","提示",MB_ICONINFORMATION); 
			return ; 
		} 
		 
		POSITION timePos = m_holidayTimeList.GetHeadPosition() ; 
		POSITION workPos = m_strHolidayList.GetHeadPosition() ; 
		 
		for (int n = 0 ; n < m_nIndex ; n++)  
		{ 
			m_holidayTimeList.GetNext(timePos) ; 
			m_strHolidayList.GetNext(workPos) ; 
		} 
		CHolidayChangeDlg ed ; 
		// 向节假日编辑框传送数据 
		ed.SetMonth(m_holidayTimeList.GetAt(timePos).GetMonth()) ; 
		ed.SetDay(m_holidayTimeList.GetAt(timePos).GetDay()) ; 
		ed.m_strHolidayInfo = m_strHolidayList.GetAt(workPos) ; 
		 
		if(ed.DoModal() == IDOK) 
		{ 
			m_holidayTimeList.RemoveAt(timePos) ; 
			m_strHolidayList.RemoveAt(workPos) ; 
			ShowHolidayList(ed) ; 
		}	 
	}	 
} 
 
void CSpecchDlg::OnGetdaystateMonthcalendar1(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	// TODO: Add your control notification handler code here	 
	NMDAYSTATE* pDayState = (NMDAYSTATE *)pNMHDR ; 
	#define BOLDDAY(ds,iDay) if(iDay>0 && iDay<32)\ 
                            (ds)|=(0x00000001<<(iDay-1)) 
	MONTHDAYSTATE mdState[3] ; 
	INT i , iMax ; 
	iMax = pDayState->cDayState ; 
 
	for(i = 0 ; i < iMax ; i++) 
	{ 
		mdState[i] = (MONTHDAYSTATE)0 ; 
		BOLDDAY(mdState[i] , 13) ; 
	} 
	pDayState->prgDayState = mdState ;	*pResult = 0; 
} 
 
// 语音设置按钮的响应函数 
void CSpecchDlg::OnSoundset()  
{ 
	// TODO: Add your control notification handler code here 
	CSoundSet ed ;     // 向语音设置对话框传送数据 
	ed.SetRate(m_rate) ; 
	ed.SetVolume(m_volume) ; 
	if(ed.DoModal() == IDOK) 
	{ 
		m_rate = ed.GetRate() ; 
		m_volume = ed.GetVolume() ; 
	} 
} 
 
// 闹钟设置按钮的响应函数 
void CSpecchDlg::OnAlarm()  
{ 
	// TODO: Add your control notification handler code here 
	CAlarmSet ed ; 
	CString strTemp ; 
	strTemp.Format("%d" , m_alarmHour) ; 
	ed.m_strHour = strTemp ; 
	strTemp.Format("%d" , m_alarmMinute) ; 
	ed.m_strMinute = strTemp ; 
	ed.m_warnContent = m_strSpeakContent[0] ; 
	ed.m_warnType = m_warnType[0] ; 
	ed.m_speakType = m_speaker[0] ; 
	ed.m_type = m_speakType[0] ; 
	ed.SetWhichDayAlarm(m_whichDayAlarm) ; 
	CString strWeek = "星期日星期一星期二星期三星期四星期五星期六" ; 
 
	if(ed.DoModal() == IDOK) 
	{ 
		m_speakType[0] = ed.m_type ; 
		m_speaker[0] = ed.m_speakType ; 
		m_strSpeakContent[0] = ed.m_warnContent ; 
		m_warnType[0] = ed.m_warnType ; 
		m_alarmMinute = atoi(ed.m_strMinute) ; 
		m_alarmHour = atoi(ed.m_strHour) ; 
		m_strWarnType[0] = GetWarnString(ed.m_warnType) ; 
		if(ed.m_bChangeMusic == TRUE) 
		{ 
			m_musicPath[0] = ed.m_musicPath ; 
		} 
 
		for(int i = 0 ; i < 7 ; i++) 
		{ 
			if(ed.m_bWhichDayAlarm[i] == TRUE) 
			{ 
				m_whichDayAlarm[i] = 1 ; 
				m_strWhichDayAlarm[i] = strWeek.Left(6) ; 
				strWeek = strWeek.Right(strWeek.GetLength() - 6) ; 
			} 
			else 
			{ 
				m_whichDayAlarm[i] = 0 ; 
				m_strWhichDayAlarm[i] = "" ; 
				strWeek = strWeek.Right(strWeek.GetLength() - 6) ; 
			} 
		} 
		KillTimer(5) ; 
		SetTimer(5 , 1000 * 60 , NULL) ; 
	} 
} 
 
// 工作备忘设置按钮的响应函数 
void CSpecchDlg::OnWorkset()  
{ 
	// TODO: Add your control notification handler code here 
	CWorkSet ed ; 
	ed.m_speakContent = m_strSpeakContent[2] ; 
	ed.m_warnType = m_warnType[2] ; 
	ed.m_speakType = m_speaker[2] ; 
	ed.m_type = m_speakType[2] ; 
	if(ed.DoModal() == IDOK) 
	{ 
		m_speakType[2] = ed.m_type ; 
		m_speaker[2] = ed.m_speakType ; 
		m_strSpeakContent[2] = ed.m_speakContent ; 
		m_warnType[2] = ed.m_warnType ; 
		m_strWarnType[2] = GetWarnString(ed.m_warnType) ; 
		if(ed.m_bChangeMusic) 
		{ 
			m_musicPath[2] = ed.m_musicPath ; 
		}	 
	} 
} 
 
// 节假日设置按钮的响应函数 
void CSpecchDlg::OnHolidayset()  
{ 
	// TODO: Add your control notification handler code here 
	CHolidaySet ed ; 
	ed.m_speakContent = m_strSpeakContent[1] ; 
	ed.m_warnType = m_warnType[1] ; 
	ed.m_speakType = m_speaker[1] ; 
	ed.m_type = m_speakType[1] ; 
	if(ed.DoModal() == IDOK) 
	{ 
		m_speakType[1] = ed.m_type ; 
		m_speaker[1] = ed.m_speakType ; 
		m_strSpeakContent[1] = ed.m_speakContent ; 
		m_warnType[1] = ed.m_warnType ; 
		m_strWarnType[1] = GetWarnString(ed.m_warnType) ; 
		if(ed.m_bChangeMusic) 
		{ 
			m_musicPath[1] = ed.m_musicPath ; 
		}	 
	} 
} 
 
// 查看工作备忘按钮的响应函数 
void CSpecchDlg::OnViewwork()  
{ 
	// TODO: Add your control notification handler code here 
	CViewWork ed ; 
	ed.SetTimeList(m_timeList) ; 
	ed.SetWorkList(m_strWorkList) ; 
	if(ed.DoModal() == IDOK) 
	{ 
	} 
} 
 
// 对两个表格右键菜单 添加选项的响应函数 
void CSpecchDlg::OnInfoadd()  
{ 
	// TODO: Add your command handler code here 
	if (m_listIndex == 0) 
	{ 
		CWorkChangeDlg ed ; 
		if (ed.DoModal() == IDOK) 
		{			 
			ShowWorkList(ed) ; 
		} 
	} 
	if (m_listIndex == 1) 
	{ 
		CHolidayChangeDlg ed ; 
		if (ed.DoModal() == IDOK) 
		{ 
			ShowHolidayList(ed) ; 
		} 
	} 
} 
 
void CSpecchDlg::OnAbout()  
{ 
	// TODO: Add your command handler code here 
	CAboutDlg dlg; 
	dlg.DoModal();	 
} 
 
/////////////////////////////////////////////////////////////////////////// 
/////                   读取文件                                      ///// 
/////                                                                 ///// 
 
void CSpecchDlg::ReadFileData() 
{ 
	CFile SourceFile ;    // 数据文件 
	CString SourceData ;  // 定义一临时变量保存一条记录 
	SourceFile.Open("Info.txt" , CFile::modeRead) ; 
	CArchive ar(&SourceFile , CArchive::load) ; 
	int n = 0 ; 
 
	while(NULL != ar.ReadString(SourceData))  // 循环读取文件,直到文件结束 
	{ 
		if ((CString)SourceData == "	时间				工作" ||  
			SourceData == "------------------------------------------" || 
			SourceData == "		时间		节假日") 
		{ 
		} 
		else if ((CString)SourceData.Left(strlen("	闹钟提醒语音内容:	")) == "	闹钟提醒语音内容:	")  
		{ 
			m_strSpeakContent[0] = SourceData.Right(SourceData.GetLength() - strlen("	闹钟提醒语音内容:	")) ; 
		} 
		else if ((CString)SourceData.Left(strlen("	节假日提醒语音内容:	")) == "	节假日提醒语音内容:	") 
		{ 
			m_strSpeakContent[1] = SourceData.Right(SourceData.GetLength() - strlen("	节假日提醒语音内容:	")) ; 
		} 
		else if ((CString)SourceData.Left(strlen("	工作备忘提示语音内容:	")) == "	工作备忘提示语音内容:	") 
		{ 
			m_strSpeakContent[2] = SourceData.Right(SourceData.GetLength() - strlen("	工作备忘提示语音内容:	")) ; 
		} 
		else if ((CString)SourceData.Left(strlen("发音人物:	")) == "发音人物:	") 
		{ 
			SourceData = SourceData.Right(SourceData.GetLength() - strlen("发音人物:	闹钟:")) ; 
			CString speaker = SourceData.Left(SourceData.Find("	节假日:")) ; 
			m_speaker[0] = speaker ; 
			m_speakType[0] = GetSpeaker(speaker) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - strlen(speaker) - strlen("	节假日:")) ; 
			speaker = SourceData.Left(SourceData.Find("	工作备忘:")) ; 
			m_speaker[1] = speaker ; 
			m_speakType[1] = GetSpeaker(speaker) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - strlen(speaker) - strlen("	工作备忘:")) ; 
			m_speaker[2] = SourceData ; 
			m_speakType[2] = GetSpeaker(SourceData) ; 
		} 
		else if((CString)SourceData.Left(strlen("	音量:		")) == "	音量:		") 
		{ 
			SourceData = SourceData.Right(SourceData.GetLength() - strlen("	音量:		")) ; 
			m_volume =atoi(SourceData.Left(SourceData.Find("		音速:		"))) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("		音速:		") 
				- strlen("		音速:		")) ; 
			m_rate = atoi(SourceData) ; 
		} 
		else if((CString)SourceData.Left(strlen("提示类型:	")) == "提示类型:	") 
		{ 
			SourceData = SourceData.Right(SourceData.GetLength() - strlen("提示类型:	闹钟:")) ; 
			CString strWarnType = SourceData.Left(SourceData.Find("	节假日:")) ; 
			m_strWarnType[0] = strWarnType ; 
			m_warnType[0] = GetWarnType(strWarnType) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("	节假日:") - 
				strlen("	节假日:")) ; 
			strWarnType = SourceData.Left(SourceData.Find("	工作备忘:")) ; 
			m_strWarnType[1] = strWarnType ; 
			m_warnType[1] = GetWarnType(strWarnType) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("	工作备忘:") - 
				strlen("	工作备忘:")) ; 
			m_strWarnType[2] = SourceData ; 
			m_warnType[2] = GetWarnType(SourceData) ; 
		} 
		else if((CString)SourceData.Left(strlen("闹钟周几提醒:	")) == "闹钟周几提醒:	") 
		{ 
			SourceData = SourceData.Right(SourceData.GetLength() - strlen("闹钟周几提醒:	")) ; 
 
			for(int i = 0 ; SourceData.GetLength() != 0 && i < 7; i++) 
			{ 
				if(SourceData.Left(6) == "星期一") 
				{ 
					m_whichDayAlarm[1] = 1 ; 
					m_strWhichDayAlarm[1] = "星期一" ; 
				} 
				else if(SourceData.Left(6) == "星期二") 
				{ 
					m_whichDayAlarm[2] = 1 ; 
					m_strWhichDayAlarm[2] = "星期二" ; 
				} 
				else if(SourceData.Left(6) == "星期三") 
				{ 
					m_whichDayAlarm[3] = 1 ; 
					m_strWhichDayAlarm[3] = "星期三" ; 
				} 
				else if(SourceData.Left(6) == "星期四") 
				{ 
					m_whichDayAlarm[4] = 1 ; 
					m_strWhichDayAlarm[4] = "星期四" ; 
				} 
				else if(SourceData.Left(6) == "星期五") 
				{ 
					m_whichDayAlarm[5] = 1 ; 
					m_strWhichDayAlarm[5] = "星期五" ; 
				} 
				else if(SourceData.Left(6) == "星期六") 
				{ 
					m_whichDayAlarm[6] = 1 ; 
					m_strWhichDayAlarm[6] = "星期六" ; 
				} 
				else if(SourceData.Left(6) == "星期日") 
				{ 
					m_whichDayAlarm[0] = 1 ; 
					m_strWhichDayAlarm[0] = "星期日" ; 
				} 
				SourceData = SourceData.Right(SourceData.GetLength() - 6) ; 
			} 
		} 
		else if ((CString)SourceData.Left(strlen("音频文件路径:	")) == "音频文件路径:	")  
		{ 
			SourceData = SourceData.Right(SourceData.GetLength() - strlen("音频文件路径:	闹钟:")) ;			 
			m_musicPath[0] = SourceData.Left(SourceData.Find("	节假日:")) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - strlen(m_musicPath[0]) - strlen("	节假日:")) ; 
			m_musicPath[1] = SourceData.Left(SourceData.Find("	工作备忘:")) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - strlen(m_musicPath[1]) - strlen("	工作备忘:")) ; 
			m_musicPath[2] = SourceData ; 
		} 
		else if((CString)SourceData.Left(strlen("	闹钟时间:	")) == "	闹钟时间:	") 
		{ 
			SourceData = SourceData.Right(SourceData.GetLength() - strlen("	闹钟时间:	")) ; 
			m_alarmHour = atoi(SourceData.Left(SourceData.Find(":"))) ; 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find(":") - strlen(":")) ; 
			m_alarmMinute = atoi(SourceData) ; 
		} 
		else if((CString)SourceData.Left(strlen("时间:	")) == "时间:	") 
		{ 
			CString strYear , strMonth , strDay , strHour , strMinute , strWorkInfo ; 
			SourceData = SourceData.Right(SourceData.GetLength() - strlen("时间:	")) ; 
			 
			strYear = SourceData.Left(SourceData.Find("&年")) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("&年") - 3) ; 
			strMonth = SourceData.Left(SourceData.Find("&月")) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("&月") - 3) ; 
			strDay = SourceData.Left(SourceData.Find("&号")) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("&号") - 3) ; 
			strHour = SourceData.Left(SourceData.Find("&点")) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("&点") - 3) ; 
			strMinute = SourceData.Left(SourceData.Find("&分")) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("节假日内容:") - 12) ; 
			strWorkInfo = SourceData ; 
			 
			CTime timeTemp(atoi(strYear) , atoi(strMonth) , atoi(strDay) , atoi(strHour) , 
				atoi(strMinute) , 0 , 0) ; 
			m_holidayTimeList.AddTail(timeTemp) ; 
			m_strHolidayList.AddTail(strWorkInfo) ; 
		}	 
		else 
		{ 
			CString strYear , strMonth , strDay , strHour , strMinute , strWorkInfo ; 
			strYear = SourceData.Left(SourceData.Find("&年")) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("&年") - 3) ; 
			strMonth = SourceData.Left(SourceData.Find("&月")) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("&月") - 3) ; 
			strDay = SourceData.Left(SourceData.Find("&号")) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("&号") - 3) ; 
			strHour = SourceData.Left(SourceData.Find("&点")) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("&点") - 3) ; 
			strMinute = SourceData.Left(SourceData.Find("&分")) ; 
 
			SourceData = SourceData.Right(SourceData.GetLength() - SourceData.Find("工作内容:") - 10) ; 
			strWorkInfo = SourceData ; 
			 
			CTime timeTemp(atoi(strYear) , atoi(strMonth) , atoi(strDay) , atoi(strHour) , 
				atoi(strMinute) , 0 , 0) ; 
			m_timeList.AddTail(timeTemp) ; 
			m_strWorkList.AddTail(strWorkInfo) ; 
		} 
		n++ ; 
	} 
	ar.Close() ; 
	SourceFile.Close() ; 
} 
 
/////////////////////////////////////////////////////////////////////////// 
/////                    写入文件                                     ///// 
/////                                                                 ///// 
void CSpecchDlg::WriteFileData() 
{ 
	CFile SourceFile ;               //数据文件 
	CString SourceData ;			 //定义一临时变量保存一条记录 
	SourceFile.Open("Info.txt" , CFile::modeCreate | CFile::modeWrite) ; 
	 
	CArchive ar(&SourceFile , CArchive::store) ; 
	CString strTitle = "	时间				工作" ; 
	SourceData = strTitle + "\r\n"; 
	ar.WriteString(SourceData) ; 
 
	POSITION timePos = m_timeList.GetHeadPosition() ; 
	workPos = m_strWorkList.GetHeadPosition() ; 
	for ( ; timePos != NULL ; m_timeList.GetNext(timePos)) 
	{ 
		CString strYear , strMonth , strDay , strHour , strMinute , strWorkInfo ; 
		strYear.Format("%d" , m_timeList.GetAt(timePos).GetYear()) ; 
		strMonth.Format("%d" , m_timeList.GetAt(timePos).GetMonth()) ; 
		strDay.Format("%d" , m_timeList.GetAt(timePos).GetDay()) ; 
		strHour.Format("%d" ,m_timeList.GetAt(timePos).GetHour()) ; 
		strMinute.Format("%d" , m_timeList.GetAt(timePos).GetMinute()) ; 
		strWorkInfo = m_strWorkList.GetAt(workPos) ; 
		SourceData = strYear + "&年" + strMonth + "&月" + strDay + "&号" + strHour + "&点" + 
			strMinute + "&分	工作内容:" + strWorkInfo + "\r\n"; 
		ar.WriteString(SourceData) ; 
		m_strWorkList.GetNext(workPos) ; 
	} 
 
	CString strTemp = "------------------------------------------" ; 
	SourceData = strTemp + "\r\n" ; 
	ar.WriteString(SourceData) ; 
 
	strTemp = "		时间		节假日" ; 
	SourceData = strTemp + "\r\n" ; 
	ar.WriteString(SourceData) ; 
	 
	timePos = m_holidayTimeList.GetHeadPosition() ; 
	workPos = m_strHolidayList.GetHeadPosition() ; 
	for( ; timePos != NULL ; m_holidayTimeList.GetNext(timePos)) 
	{ 
		CString strYear , strMonth , strDay , strHour , strMinute , strWorkInfo ; 
		strYear.Format("%d" , m_holidayTimeList.GetAt(timePos).GetYear()) ; 
		strMonth.Format("%d" , m_holidayTimeList.GetAt(timePos).GetMonth()) ; 
		strDay.Format("%d" , m_holidayTimeList.GetAt(timePos).GetDay()) ; 
		strHour.Format("%d" ,m_holidayTimeList.GetAt(timePos).GetHour()) ; 
		strMinute.Format("%d" , m_holidayTimeList.GetAt(timePos).GetMinute()) ; 
		strWorkInfo = m_strHolidayList.GetAt(workPos) ; 
		SourceData = "时间:	" +  strYear + "&年" + strMonth + "&月" + strDay + "&号" + strHour + "&点" + 
			strMinute + "&分	节假日内容:" + strWorkInfo + "\r\n"; 
		ar.WriteString(SourceData) ; 
		m_strHolidayList.GetNext(workPos) ;	 
	} 
 
	strTemp = "------------------------------------------" ; 
	SourceData = strTemp + "\r\n" ; 
	ar.WriteString(SourceData) ; 
 
	SourceData = "音频文件路径:	闹钟:" + m_musicPath[0] + "	节假日:" + 
		m_musicPath[1] + "	工作备忘:" + m_musicPath[2] + "\r\n" ; 
	ar.WriteString(SourceData) ; 
	strTemp = "------------------------------------------" ; 
	SourceData = strTemp + "\r\n" ; 
	ar.WriteString(SourceData) ; 
	 
	SourceData = "发音人物:	闹钟:" + m_speaker[0] + "	节假日:" + 
		m_speaker[1] + "	工作备忘:" + m_speaker[2] + "\r\n" ; 
	ar.WriteString(SourceData) ; 
	SourceData = strTemp + "\r\n" ; 
	ar.WriteString(SourceData) ; 
 
	SourceData = "提示类型:	闹钟:" + m_strWarnType[0] + "	节假日:" + 
		m_strWarnType[1] + "	工作备忘:" + m_strWarnType[2] + "\r\n" ; 
	ar.WriteString(SourceData) ; 
	SourceData = strTemp + "\r\n" ; 
	ar.WriteString(SourceData) ; 
 
	SourceData = "闹钟周几提醒:	" ; 
	for(int i = 0 ; i < 7 ; i++) 
	{ 
		SourceData = SourceData + m_strWhichDayAlarm[i] ; 
	} 
	SourceData = SourceData + "\r\n" ; 
	ar.WriteString(SourceData) ; 
 
	CString strTemp1 ; 
	SourceData = "	闹钟时间:	" ; 
	strTemp.Format("%d" , m_alarmHour) ; 
	strTemp1.Format("%d" , m_alarmMinute) ; 
	SourceData = SourceData + strTemp + ":" + strTemp1 + "\r\n" ; 
	ar.WriteString(SourceData) ; 
	strTemp = "------------------------------------------" ; 
	SourceData = strTemp + "\r\n" ; 
	ar.WriteString(SourceData) ; 
 
	CString speakContent[3] = {"	闹钟提醒语音内容:	" , "	节假日提醒语音内容:	" , 
		"	工作备忘提示语音内容:	"} ; 
	 
	for (int j = 0 ; j < 3 ; j++)  
	{ 
		SourceData = speakContent[j] + m_strSpeakContent[j] + "\r\n" ; 
		ar.WriteString(SourceData) ; 
		 
		SourceData = strTemp + "\r\n" ; 
		ar.WriteString(SourceData) ; 
	} 
 
	SourceData = strTemp + "\r\n" ; 
	ar.WriteString(SourceData) ; 
 
	strTemp1.Format("%d" , m_volume) ; 
	strTemp.Format("%d" , m_rate) ; 
	SourceData = "	音量:		" + strTemp1 + "		音速:		" + strTemp + "\r\n" ; 
	ar.WriteString(SourceData) ; 
 
	ar.Close() ; 
	SourceFile.Close() ; 
} 
 
// 两个表格右键菜单 删除选项的响应函数 
void CSpecchDlg::OnDel()  
{ 
	// TODO: Add your command handler code here 
	if(m_listIndex == 0) 
	{ 
		POSITION pos = m_list.GetFirstSelectedItemPosition() ; 
		m_nIndex = m_list.GetNextSelectedItem(pos) ;       // 得到项目索引 
 
		if(m_nIndex == -1) 
		{ 
			MessageBox("请选择一项再删除!","提示",MB_ICONINFORMATION); 
			return ; 
		} 
		POSITION workPos = m_strWorkList.GetHeadPosition() ; 
		POSITION timePos = m_timeList.GetHeadPosition() ;  
		POSITION timePosTemp = m_timeList.GetHeadPosition() ; 
		POSITION workPosTemp = m_strWorkList.GetHeadPosition() ; 
 
		for ( ; timePos != NULL && (m_timeList.GetAt(timePos).GetYear() != m_time.GetYear() 
			|| m_timeList.GetAt(timePos).GetMonth() != m_time.GetMonth() || 
			m_timeList.GetAt(timePos).GetDay() != m_time.GetDay()) ; m_timeList.GetNext(timePos))  
		{ 
			m_strWorkList.GetNext(workPos) ; 
			m_timeList.GetNext(timePosTemp) ; 
			m_strWorkList.GetNext(workPosTemp) ; 
		} 
 
		for (int n = 0 ; n < m_nIndex ; n++)  
		{ 
			m_timeList.GetNext(timePos) ; 
			m_strWorkList.GetNext(workPos) ; 
		} 
 
		CTime firstAlarmTime = m_timeList.GetAt(m_workTimePos) ; 
		CString firstAlarmInfo = m_strWorkList.GetAt(m_strWorkPos) ; 
		CTime deltedTime = m_timeList.GetAt(timePos) ; 
		CTime secondAlarmTime = firstAlarmTime ; 
		CString secondAlarmInfo = firstAlarmInfo ; 
		m_timeList.GetNext(m_workTimePos) ; 
		m_strWorkList.GetNext(m_strWorkPos) ; 
		if(m_workTimePos != NULL) 
		{ 
			secondAlarmTime = m_timeList.GetAt(m_workTimePos) ; 
			secondAlarmInfo = m_strWorkList.GetAt(m_strWorkPos) ; 
		} 
		 
		m_list.DeleteItem(m_nIndex) ; 
		 
		UINT flag = LVIS_SELECTED|LVIS_FOCUSED; 
		m_list.SetItemState(m_nIndex-1, flag, flag); 
		m_timeList.RemoveAt(timePos) ;        // 删除指定链表节点 
		m_strWorkList.RemoveAt(workPos) ;     // 删除指定链表节点 
 
		if(deltedTime == firstAlarmTime) 
		{ 
			if(firstAlarmTime == secondAlarmTime) 
			{ 
				m_workTimePos = m_timeList.GetHeadPosition() ; 
				m_strWorkPos = m_strWorkList.GetHeadPosition() ; 
			} 
			else 
			{ 
				m_workTimePos = m_timeList.Find(secondAlarmTime) ; 
				m_strWorkPos = m_strWorkList.Find(secondAlarmInfo) ; 
			} 
		} 
		else 
		{ 
			m_workTimePos = m_timeList.Find(firstAlarmTime) ; 
			m_strWorkPos = m_strWorkList.Find(firstAlarmInfo) ; 
		} 
 
	} 
	if(m_listIndex == 1) 
	{ 
		POSITION pos = m_holidayList.GetFirstSelectedItemPosition() ; 
		m_nIndex = m_holidayList.GetNextSelectedItem(pos) ;       // 得到下一个索引 
		 
		if(m_nIndex == -1) 
		{ 
			MessageBox("请选择一项再删除!","提示",MB_ICONINFORMATION); 
			return ; 
		} 
		 
		POSITION timePos = m_holidayTimeList.GetHeadPosition() ; 
		POSITION workPos = m_strHolidayList.GetHeadPosition() ; 
		 
		for (int n = 0 ; n < m_nIndex ; n++)  
		{ 
			m_holidayTimeList.GetNext(timePos) ; 
			m_strHolidayList.GetNext(workPos) ; 
		} 
 
		m_holidayList.DeleteItem(m_nIndex) ; 
		UINT flag = LVIS_SELECTED|LVIS_FOCUSED; 
		m_list.SetItemState(m_nIndex-1, flag, flag); 
 
		m_holidayTimeList.RemoveAt(timePos) ; 
		m_strHolidayList.RemoveAt(workPos) ; 
	} 
} 
 
void CSpecchDlg::ShowHolidayList() 
{ 
	POSITION pos = m_holidayTimeList.GetHeadPosition() ; 
	POSITION workPos = m_strHolidayList.GetHeadPosition() ; 
 
	for (int n = 0 ; pos != NULL ; n++) 
	{ 
		if(n == 0) 
		{ 
			m_holidayList.DeleteAllItems() ; 
		} 
		CString strTime ; 
		strTime.Format("%d月%d号" , m_holidayTimeList.GetAt(pos).GetMonth() , m_holidayTimeList.GetAt(pos).GetDay()) ; 
		m_holidayList.InsertItem(n , strTime) ; 
		m_holidayList.SetItemText(n , 1 , m_strWorkList.GetAt(workPos)) ; 
		m_holidayTimeList.GetNext(pos) ; 
		m_strHolidayList.GetNext(workPos) ; 
	} 
} 
 
// 得到声音类型 
int CSpecchDlg::GetSpeaker(CString strspeaker) 
{ 
	if(strspeaker == "Mary") 
	{ 
		return 0 ; 
	} 
	else if (strspeaker == "Mike")  
	{ 
		return 1 ; 
	} 
	else 
	{ 
		return 2 ; 
	} 
} 
 
// 得到提示类型 
int CSpecchDlg::GetWarnType(CString strWarnType) 
{ 
	if(strWarnType == "气泡提示") 
	{ 
		return 0 ; 
	} 
	else if(strWarnType == "语音提示") 
	{ 
		return 1 ; 
	} 
	else 
	{ 
		return 2 ; 
	} 
} 
 
CString CSpecchDlg::GetWarnString(int i) 
{ 
	if(i == 0) 
	{ 
		return "气泡提示" ; 
	} 
	else if(i == 1) 
	{ 
		return "语音提示" ; 
	} 
	else 
	{ 
		return "播放音乐" ; 
	} 
} 
 
// 判断是否时间到了 
void CSpecchDlg::IsTimeUp() 
{ 
	if(m_workTimePos != NULL && m_timeList.GetAt(m_workTimePos).GetYear() == (CTime::GetCurrentTime()).GetYear() && 
		m_timeList.GetAt(m_workTimePos).GetMonth() == (CTime::GetCurrentTime()).GetMonth() && 
		m_timeList.GetAt(m_workTimePos).GetDay() == (CTime::GetCurrentTime()).GetDay() && 
		m_timeList.GetAt(m_workTimePos).GetHour() == (CTime::GetCurrentTime()).GetHour() && 
		m_timeList.GetAt(m_workTimePos).GetMinute() == (CTime::GetCurrentTime()).GetMinute()) 
	{ 
		if(m_warnType[2] == 0) 
		{ 
			// 气泡提示 
			_tcscpy(tnd.szInfoTitle , "提醒你") ; 
			_tcscpy(tnd.szInfo , m_strWorkList.GetAt(m_strWorkPos)) ; 
			tnd.uTimeout = 1000 ; 
			tnd.uVersion = NOTIFYICON_VERSION ; 
			Shell_NotifyIcon(NIM_MODIFY , &tnd) ; 
		} 
		else if(m_warnType[2] == 1) 
		{ 
			voiceList[2] = voice[2].GetVoices(NULL , NULL) ; 
			voice[2].SetRefVoice(voiceList[2].Item(m_speakType[2])) ; 
			voice[2].Speak(m_strSpeakContent[2] , 1) ; 
		} 
		else 
		{ 
			sndPlaySound(m_musicPath[2] , SND_ASYNC) ;		// 播放音乐 
		} 
		POSITION workTimePos = m_workTimePos ; 
		POSITION strWorkPos = m_strWorkPos ; 
		m_timeList.GetNext(m_workTimePos) ; 
		m_strWorkList.GetNext(m_strWorkPos) ; 
		if(m_workTimePos == NULL) 
		{ 
			m_workTimePos = workTimePos ; 
			m_strWorkPos = strWorkPos ; 
		} 
	} 
	if((m_alarmHour == (CTime::GetCurrentTime()).GetHour() && m_alarmMinute == 
		(CTime::GetCurrentTime()).GetMinute()) || (CTime::GetCurrentTime()).GetMinute() == 0) 
	{ 
		CString strInfo ; 
		if((CTime::GetCurrentTime()).GetMinute() == 0) 
		{ 
			strInfo.Format("%d" , (CTime::GetCurrentTime()).GetHour()) ; 
			strInfo = "现在是" + strInfo + "点" ; 
			_tcscpy(tnd.szInfoTitle , "提醒你") ; 
			_tcscpy(tnd.szInfo , strInfo) ; 
			tnd.uTimeout = 1000 ; 
			tnd.uVersion = NOTIFYICON_VERSION ; 
			Shell_NotifyIcon(NIM_MODIFY , &tnd) ;	 
		} 
		else 
		{ 
			strInfo = "您设定的闹铃时间到了!" ; 
		} 
		if(m_warnType[0] == 0 && m_whichDayAlarm[(CTime::GetCurrentTime()).GetDayOfWeek() - 1]) 
		{ 
			_tcscpy(tnd.szInfoTitle , "提醒你") ; 
			_tcscpy(tnd.szInfo , strInfo) ; 
			tnd.uTimeout = 1000 ; 
			tnd.uVersion = NOTIFYICON_VERSION ; 
			Shell_NotifyIcon(NIM_MODIFY , &tnd) ;	 
		} 
		else if(m_warnType[0] == 1 && m_whichDayAlarm[(CTime::GetCurrentTime()).GetDayOfWeek() - 1]) 
		{ 
			voiceList[0] = voice[0].GetVoices(NULL , NULL) ; 
			voice[0].SetRefVoice(voiceList[0].Item(m_speakType[0])) ; 
			voice[0].Speak(m_strSpeakContent[0] , 1) ; 
		} 
		else if(m_warnType[0] == 2 && m_whichDayAlarm[(CTime::GetCurrentTime()).GetDayOfWeek() - 1]) 
		{ 
			sndPlaySound(m_musicPath[0] , SND_ASYNC) ;	// 播放音乐 
		} 
	} 
} 
 
void CSpecchDlg::OnDestroy()  
{ 
	CDialog::OnDestroy(); 
	// TODO: Add your message handler code here 
	Shell_NotifyIcon(NIM_DELETE, &tnd);      // 当窗口消失的时候删除托盘的图标	 
} 
 
// 在日历表上点击鼠标的响应函数 
void CSpecchDlg::OnSelectMonthcalendar1(NMHDR* pNMHDR, LRESULT* pResult)  
{ 
	// TODO: Add your control notification handler code here 
	UpdateData(TRUE) ; 
	m_monthCalCtrl->GetCurSel(&m_st) ; 
 
	m_st.wHour = 0 ; 
	m_st.wMinute = 0 ; 
	m_st.wMilliseconds = 0 ; 
	m_time = CTime(m_st) ; 
 
	ShowWorkList() ;	 
	UpdateData(FALSE) ; 
	*pResult = 0; 
} 
 
// 隐藏窗口按钮的响应函数 
void CSpecchDlg::OnHide()  
{ 
	// TODO: Add your control notification handler code here 
	m_isShow = FALSE ; 
	this->ShowWindow(SW_HIDE) ; 
} 
 
void CSpecchDlg::ShowWorkList(CWorkChangeDlg &ed) 
{ 
	CTime timeTemp(atoi(ed.m_strYear) , atoi(ed.m_strMonth) , atoi(ed.m_strDay) 
				, atoi(ed.m_strHour) , atoi(ed.m_strMinute) , 0 , 0) ; 
	 
	CTime firstAlarmTime ; 
	CString firstAlarmInfo ; 
	CTime currentTime = CTime::GetCurrentTime() ; 
 
	if(m_workTimePos != NULL) 
	{ 
		firstAlarmTime = m_timeList.GetAt(m_workTimePos) ; 
		firstAlarmInfo = m_strWorkList.GetAt(m_strWorkPos) ; 
//		MessageBox(m_strWorkList.GetAt(m_strWorkPos)) ; 
//		MessageBox("firstalarm no null") ; 
	} 
//	else 
//	{ 
//		MessageBox("firstalarm") ; 
//	} 
//			 
	if (m_strWorkList.IsEmpty())  
	{ 
		m_timeList.AddTail(timeTemp) ; 
		m_strWorkList.AddTail(ed.m_strWorkInfo) ; 
	} 
	else 
	{ 
		pos = m_timeList.GetHeadPosition() ;		// 得到链表的头节点 
		workPos = m_strWorkList.GetHeadPosition() ; 
		// 在指定的节点后插入一个时间 
		for (; pos != NULL && m_timeList.GetAt(pos) < timeTemp ; m_timeList.GetNext(pos))  
		{ 
			m_strWorkList.GetNext(workPos) ; 
		} 
		if (pos == NULL)  
		{ 
			m_timeList.AddTail(timeTemp) ; 
			m_strWorkList.AddTail(ed.m_strWorkInfo) ; 
			if(timeTemp > CTime::GetCurrentTime() && timeTemp.GetYear() == currentTime.GetYear() 
				&& timeTemp.GetMonth() == currentTime.GetMonth() 
				&& timeTemp.GetDay() == currentTime.GetDay()) 
			{ 
				m_workTimePos = m_timeList.GetHeadPosition() ; 
				m_strWorkPos = m_strWorkList.GetHeadPosition() ; 
			} 
		} 
		else 
		{ 
			m_timeList.InsertBefore(pos , timeTemp) ; 
			m_strWorkList.InsertBefore(workPos , ed.m_strWorkInfo) ; 
			if(timeTemp > CTime::GetCurrentTime() && timeTemp.GetYear() == currentTime.GetYear() 
				&& timeTemp.GetMonth() == currentTime.GetMonth() 
				&& timeTemp.GetDay() == currentTime.GetDay()) 
			{ 
				if(timeTemp < firstAlarmTime || firstAlarmTime < CTime::GetCurrentTime()) 
				{ 
					m_workTimePos = m_timeList.Find(timeTemp) ; 
					m_strWorkPos = m_strWorkList.Find(ed.m_strWorkInfo) ; 
//					MessageBox(m_strWorkList.GetAt(m_strWorkPos)) ; 
//					MessageBox("cuo le") ; 
				} 
				else 
				{ 
					m_workTimePos = m_timeList.Find(firstAlarmTime) ; 
					m_strWorkPos = m_strWorkList.Find(firstAlarmInfo) ; 
//					MessageBox(m_strWorkList.GetAt(m_strWorkPos)) ; 
//					MessageBox("dui le") ; 
				} 
			} 
		} 
	} 
 
	ShowWorkList() ; 
} 
 
void CSpecchDlg::ShowHolidayList(CHolidayChangeDlg &ed) 
{ 
	CTime timeTemp(2005 , atoi(ed.m_strMonth) , atoi(ed.m_strDay) , 0 , 0 , 0 , 0) ; 
 
	if (m_strHolidayList.IsEmpty())  
	{ 
		m_holidayTimeList.AddTail(timeTemp) ; 
		m_strHolidayList.AddTail(ed.m_strHolidayInfo) ; 
	} 
	else 
	{ 
		// 得到链表的头节点 
		pos = m_holidayTimeList.GetHeadPosition() ; 
		workPos = m_strHolidayList.GetHeadPosition() ; 
		// 在指定的节点后插入一个时间 
		for (; pos != NULL && m_holidayTimeList.GetAt(pos) < timeTemp ; m_holidayTimeList.GetNext(pos))  
		{ 
			m_strHolidayList.GetNext(workPos) ; 
		} 
		if (pos == NULL)  
		{ 
			m_holidayTimeList.AddTail(timeTemp) ; 
			m_strHolidayList.AddTail(ed.m_strHolidayInfo) ; 
		} 
		else 
		{ 
			m_holidayTimeList.InsertBefore(pos , timeTemp) ; 
			m_strHolidayList.InsertBefore(workPos , ed.m_strHolidayInfo) ; 
		} 
	} 
	ShowHolidayList() ; 
} 
 
// 显示工作备忘表格的函数m 
void CSpecchDlg::ShowWorkList() 
{ 
	pos = m_timeList.GetHeadPosition() ; 
	workPos = m_strWorkList.GetHeadPosition() ; 
	 
	for ( ; pos != NULL && (m_timeList.GetAt(pos).GetYear() != m_time.GetYear() 
		|| m_timeList.GetAt(pos).GetMonth() != m_time.GetMonth()  
		|| m_timeList.GetAt(pos).GetDay() != m_time.GetDay()) ; m_timeList.GetNext(pos))  
	{ 
		m_strWorkList.GetNext(workPos) ; 
	} 
	if(pos == NULL) 
	{ 
		m_list.DeleteAllItems() ; 
		AfxMessageBox("您好,您在该天没有任务工作备忘记录!") ; 
	} 
	int n = 0 ; 
	for (; pos != NULL && m_timeList.GetAt(pos).GetYear() == m_time.GetYear() 
		&& m_timeList.GetAt(pos).GetMonth() == m_time.GetMonth() 
		&& m_timeList.GetAt(pos).GetDay() == m_time.GetDay() ; m_timeList.GetNext(pos)) 
	{ 
		if(m_bFind == FALSE && m_timeList.GetAt(pos) > CTime::GetCurrentTime()) 
		{ 
			m_workTimePos = pos ; 
			m_strWorkPos = workPos ; 
			m_bFind = TRUE ; 
		} 
		if (n == 0)  
		{ 
			m_list.DeleteAllItems() ; 
		} 
		CString strTime ; 
		strTime.Format("%d:%d" , m_timeList.GetAt(pos).GetHour() , m_timeList.GetAt(pos).GetMinute()) ; 
		m_list.InsertItem(n , strTime) ; 
		m_list.SetItemText(n , 1 , m_strWorkList.GetAt(workPos)) ; 
		m_strWorkList.GetNext(workPos) ; 
		n++ ; 
	} 
}