📄 listdialog.cpp
字号:
// ListDialog.cpp : implementation file
//
#include "stdafx.h"
#include "Scanner.h"
#include "ListDialog.h"
#include "ScannerDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CListDialog dialog
CListDialog::CListDialog(CWnd* pParent /*=NULL*/)
: CDialog(CListDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CListDialog)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pParent=(CScannerDlg*)pParent;//获取父窗口指针
}
void CListDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CListDialog)
DDX_Control(pDX, IDC_RICHTEXTCTRL1, m_IdList);
DDX_Control(pDX, IDC_RICHTEXTCTRL2, m_ConstList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CListDialog, CDialog)
//{{AFX_MSG_MAP(CListDialog)
ON_BN_CLICKED(IDC_BUTTON1, OnSave)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//初始化子对话框
/////////////////////////////////////////////////////////////////////////////
BOOL CListDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_IdList.SetText(m_pParent->GetAllId());//调用父窗口函数显示所有的标识符
m_ConstList.SetText(m_pParent->GetAllConst());//调用父窗口显示所有的常数
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
/////////////////////////////////////////////////////////////////////////////
//列表保存
/////////////////////////////////////////////////////////////////////////////
void CListDialog::OnSave()
{
CString Buf;
//打开文件对话框
CFileDialog OFile(false,"*.txt","*.txt",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"Text Files(*.txt)|*.txt");
if(OFile.DoModal()==IDOK)
{
CString FileName=OFile.GetPathName();//获取当前文件路径
CFile file;
file.Open(FileName,CFile::modeCreate|CFile::modeWrite);//打开文件
Buf="标识符\r\n"+m_IdList.GetText()+"常数\r\n"+m_ConstList.GetText();//将文本控件内容读进缓冲区
UINT FileSize=Buf.GetLength();//获取缓冲区内容大小
file.Write(Buf.GetBuffer(FileSize),FileSize);//将缓冲区内容写进文件
file.Close();//关闭文件
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -