opendlg.cpp

来自「数据结构课程设计 图形界面 数据结构课程设计 图形界面 文本编辑器用MFC做」· C++ 代码 · 共 83 行

CPP
83
字号
// openDlg.cpp : implementation file
//

#include "stdafx.h"
#include "kecheng.h"
#include "openDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CopenDlg dialog


CopenDlg::CopenDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CopenDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CopenDlg)
	m_filename = _T("me.txt");
	//}}AFX_DATA_INIT
}


void CopenDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CopenDlg)
	DDX_Text(pDX, IDC_EDIT1, m_filename);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CopenDlg, CDialog)
	//{{AFX_MSG_MAP(CopenDlg)
	ON_BN_CLICKED(IDC_VIEW, OnView)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CopenDlg message handlers

void CopenDlg::OnView() 
{
	// TODO: Add your control notification handler code here
	MessageBox("请直接填入file.dat或me.txt\n然后点击“显示内容”\n","消息",MB_OK|MB_ICONEXCLAMATION );
	char szFilter[]="ALL Files(*.*)\0*.*\0Test Files(*.txt)\0*.txt\0Dat Files(*.dat)\0*.dat\0\0";
	CString msg="File to open:";
	CFileDialog dlg(true);//显示对话框 
	dlg.m_ofn.lpstrFilter=(LPSTR)szFilter;//初始化对话框
	if(dlg.DoModal()==IDOK)
	{
		msg+=dlg.GetFileName();
		m_filename=dlg.GetFileName();
		//MessageBox(msg);
	}
	UpdateData(FALSE);
}

void CopenDlg::OnCancel() 
{
	//exit(0);	// TODO: Add extra cleanup here
	//CDialog::OnOK();
	CDialog::OnCancel();
}

BOOL CopenDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_tooltips3.Create(this);

	m_tooltips3.ADDTool(IDC_EDIT1,"请输入文件名,只能打开与之在同目录下的文件!!!!");
	m_tooltips3.ADDTool(IDC_VIEW,"浏览文件,暂不支持此功能!!!");
	m_tooltips3.ADDTool(IDOK,"确定操作");
	m_tooltips3.ADDTool(IDCANCEL,"取消操作");
	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 + -
显示快捷键?