⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resultdlg.cpp

📁 数据结构链表的演示程序
💻 CPP
字号:
// ResultDlg.cpp : implementation file
//

#include "stdafx.h"
#include "LandSoft.h"
#include "ResultDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CResultDlg dialog


CResultDlg::CResultDlg(CWnd* pParent,CString results,BOOL show,BYTE type,
					   BYTE typenum,long * array,UINT slipnum,BOOL show2,UINT xzoom,BOOL stand)
	: CDialog(CResultDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CResultDlg)
	m_Results = results;
	//}}AFX_DATA_INIT
	m_bStand=stand;
	m_bReadOnly=TRUE;
	m_bShow=show;
	m_bShow2=show2;
	m_pArray=array;
	m_nType=type;
	m_nTypeNum=typenum;
	m_nSlipNum=slipnum;
	m_nXZoom=xzoom;
	m_OldResults=results;
}


void CResultDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CResultDlg)
	DDX_Control(pDX, IDC_EDIT_RESULT, m_ctrEdit);
	DDX_Control(pDX, IDC_BOTTON_IMAGE2, m_BottonImage2);
	DDX_Control(pDX, IDC_BOTTON_IMAGE, m_BottonImage);
	DDX_Text(pDX, IDC_EDIT_RESULT, m_Results);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CResultDlg, CDialog)
	//{{AFX_MSG_MAP(CResultDlg)
	ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
	ON_BN_CLICKED(IDC_BOTTON_IMAGE, OnBottonImage)
	ON_BN_CLICKED(IDC_BOTTON_IMAGE2, OnBottonImage2)
	ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit)
	ON_BN_CLICKED(IDC_BUTTON_SAVEEDIT, OnButtonSaveedit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CResultDlg message handlers

void CResultDlg::OnButtonSave() 
{
	CFile file;
	CString path,string;

	CFileDialog FileDialogBox
		(FALSE,"txt","*.txt",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
		"Text file(*.txt)|*.TXT|",NULL);		
	if(FileDialogBox.DoModal()==IDOK)
	{
		CString Eo=FileDialogBox.GetFileExt();
		Eo.MakeUpper();
		if(Eo=="TXT")
		{
			path=FileDialogBox.GetPathName();
			LPCTSTR nName=LPCTSTR(path);
			file.Open(path,CFile::modeCreate|CFile::modeWrite);
			file.Write(LPCTSTR(m_OldResults),m_OldResults.GetLength());
			file.Close();
		}
		else
			AfxMessageBox("请确认文件名扩展名是否为 .TXT !",MB_OK,0);
	}
}

void CResultDlg::OnBottonImage() 
{
	CPictureDlg picdlg(this,m_nType,m_pArray,m_nTypeNum,m_nSlipNum);
	picdlg.DoModal();
}

BOOL CResultDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	if(!m_bShow)
		m_BottonImage.ShowWindow(SW_HIDE);
	if(!m_bShow2)
		m_BottonImage2.ShowWindow(SW_HIDE);
	
	if(m_Results.GetLength()>64000)
		AfxMessageBox("结果数据太庞大,不能在结果窗口显示,请保存结果后,在其他字处理软件中显示!",MB_OK,NULL);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CResultDlg::OnBottonImage2() 
{
	CPicDlg2 picdlg(this,m_pArray,m_nTypeNum,m_nSlipNum,m_nXZoom,m_bStand);
	picdlg.DoModal();
}

void CResultDlg::OnButtonEdit() 
{
	m_bReadOnly=!m_bReadOnly;
	m_ctrEdit.SetReadOnly(m_bReadOnly);
}

void CResultDlg::OnButtonSaveedit() 
{
	UpdateData(TRUE);

	CFile file;
	CString path,string;

	CFileDialog FileDialogBox
		(FALSE,"txt","*.txt",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
		"Text file(*.txt)|*.TXT|",NULL);		
	if(FileDialogBox.DoModal()==IDOK)
	{
		CString Eo=FileDialogBox.GetFileExt();
		Eo.MakeUpper();
		if(Eo=="TXT")
		{
			path=FileDialogBox.GetPathName();
			LPCTSTR nName=LPCTSTR(path);
			file.Open(path,CFile::modeCreate|CFile::modeWrite);
			file.Write(LPCTSTR(m_Results),m_Results.GetLength());
			file.Close();
		}
		else
			AfxMessageBox("请确认文件名扩展名是否为 .TXT !",MB_OK,0);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -