Example #1
0
/*
	当MainPage窗口有子窗口要切换,但是切换的控制在子窗口内部本身,发送一个消息给
	MainPage,然后MainPage接受这个消息,再处理切换相关的事务。
*/
LRESULT CMainPage::OnChildDlgSwitchClicked(WPARAM wParam, LPARAM lParam)
{
	CSysLog sl;
	PopupDialog pdlg;
	pdlg.SetTimeout(2);
	pdlg.SetButtonText("确  定");
	int file_total_pages = 0;
	switch(wParam) {
	case DLG_FILEPICK:
		this->pDialog[DLG_PAY]->ShowWindow(SW_HIDE);
		this->pDialog[DLG_PRINTSETTING]->ShowWindow(SW_HIDE);
		this->pDialog[DLG_PREVIEW]->ShowWindow(SW_HIDE);
		this->pDialog[DLG_FILEPICK]->ShowWindow(SW_SHOW);

		break;
	case DLG_PREVIEW:
		/////////////////////////////////暂时不支持预览/////////////////////////////////////////
		sl.writeLog("文件预览请求被点击");
		pdlg.SetMessage("即将支持的功能,请稍等!");
		pdlg.DoModal();
		return 0;
		/////////////////////////////////暂时不支持预览/////////////////////////////////////////
		this->pDialog[DLG_FILEPICK]->ShowWindow(SW_HIDE);
		//将要预览的文件传递给预览对话框
		//PreviewDlg.m_fileFullPathInPreview = FilePickDlg.m_cur_path +"\\"+ FilePickDlg.m_sFileNameSelected;
		PreviewDlg.m_fileFullPathInPreview = transaction.getFilenamePrinting();
		//PreviewDlg.m_fileFullPathInPreview = "H:\\新建文件夹\\WeiYongcheng UESTC.doc";
		this->pDialog[DLG_PREVIEW]->ShowWindow(SW_SHOW);
		this->pDialog[DLG_PRINTSETTING]->ShowWindow(SW_HIDE);
		this->pDialog[DLG_PAY]->ShowWindow(SW_HIDE);
		break;
	case DLG_PRINTSETTING:
		file_total_pages = GetPagesFromFileName(transaction.getFilenamePrinting());
		if ( file_total_pages > 0) {
			transaction.setFileTotalPages(file_total_pages);
		} 
		else if ( file_total_pages == 0) {
			pdlg.SetMessage("尚未选择文件,快去选择吧");
			if (pdlg.DoModal() == IDC_DLG_MYRETURN)
				::PostMessage(this->m_hWnd,WM_CHILDSWITCH,DLG_FILEPICK,0);
			else
				::PostMessage(this->m_hWnd,WM_CHILDSWITCH,DLG_FILEPICK,0);
		}
		else {
			pdlg.SetMessage("不能获得本Document对象,请重新选择!");
			if (pdlg.DoModal() == IDC_DLG_MYRETURN)
				OnOK();
		}
		this->pDialog[DLG_FILEPICK]->ShowWindow(SW_HIDE);
		this->pDialog[DLG_PREVIEW]->ShowWindow(SW_HIDE);
		this->pDialog[DLG_PAY]->ShowWindow(SW_HIDE);
		this->pDialog[DLG_PRINTSETTING]->ShowWindow(SW_SHOW);
		break;
	case DLG_PAY:
		if (transaction.getFilenamePrinting() == "") {
			pdlg.SetMessage("尚未选择文件,请重新选择文件。");
			//如果没有选择文件,则去选择文件呀
			if (pdlg.DoModal() == IDC_DLG_MYRETURN)
				::PostMessage(this->m_hWnd,WM_CHILDSWITCH,DLG_FILEPICK,0);
			else
				::PostMessage(this->m_hWnd,WM_CHILDSWITCH,DLG_FILEPICK,0);
			return 0;
		}
		//未对待打印的文件进行设置,则去设置呀
		
		if (transaction.getPrintingTotalPages() == 0 || transaction.getPrintingCopies() == 0)
		{
			if (!transaction.getFileSettingStr().IsEmpty())	{
				pdlg.SetMessage("设置页面范围错误,请重新设置");
			}
			else
				pdlg.SetMessage("还没进行设置打印参数,去设置吧");
			if (pdlg.DoModal() == IDC_DLG_MYRETURN)
				::PostMessage(this->m_hWnd, WM_CHILDSWITCH, DLG_PRINTSETTING,0);
			else
				::PostMessage(this->m_hWnd,WM_CHILDSWITCH, DLG_PRINTSETTING,0);
			return 0;
		}
		this->pDialog[DLG_FILEPICK]->ShowWindow(SW_HIDE);
		this->pDialog[DLG_PREVIEW]->ShowWindow(SW_HIDE);
		this->pDialog[DLG_PRINTSETTING]->ShowWindow(SW_HIDE);
		this->pDialog[DLG_PAY]->ShowWindow(SW_SHOW);
		break;
	default:
		//unknown fault
		;
	}
	return 0;
}