resultdlg.cpp

来自「PL0的编译系统,使用MFC编写界面,采用浮动窗口来仿VC的环境」· C++ 代码 · 共 68 行

CPP
68
字号
// ResultDlg.cpp : implementation file
//

#include "stdafx.h"
#include "My1.h"
#include "ResultDlg.h"
#include <fstream.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

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


CResultDlg::CResultDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CResultDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CResultDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CResultDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CResultDlg)
	DDX_Control(pDX, IDC_EDIT1, m_result);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CResultDlg, CDialog)
	//{{AFX_MSG_MAP(CResultDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

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

BOOL CResultDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	fstream infile;	
	infile.open("c://Data.txt",ios::in | ios::nocreate);
	if(!infile) {
		MessageBox("failed to open file!");
		PostQuitMessage(0);
		}
	char buf[200];
	while(infile.getline(buf,200))
		{			
		m_result.FmtLines(true);
		m_result.SetFocus();
		m_result.ReplaceSel(buf,false);			
		m_result.ReplaceSel("\r\n");		
		}	
	infile.close();
	DeleteFile("c://Data.txt");
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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