📄 filerw.cpp
字号:
// FileRW.cpp : implementation file
//
#include "stdafx.h"
#include "Chapter14.h"
#include "FileRW.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFileRW dialog
CFileRW::CFileRW(CWnd* pParent /*=NULL*/)
: CDialog(CFileRW::IDD, pParent)
{
//{{AFX_DATA_INIT(CFileRW)
m_destinationPath = _T("");
m_sourcePath = _T("");
//}}AFX_DATA_INIT
}
void CFileRW::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFileRW)
DDX_Text(pDX, IDC_destination_path, m_destinationPath);
DDX_Text(pDX, IDC_source_path, m_sourcePath);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFileRW, CDialog)
//{{AFX_MSG_MAP(CFileRW)
ON_BN_CLICKED(IDC_destination, Ondestination)
ON_BN_CLICKED(IDC_source, Onsource)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFileRW message handlers
void CFileRW::Ondestination()
{
// TODO: Add your control notification handler code here
//声明一个文件夹浏览结构
LPBROWSEINFO lpbi=new BROWSEINFO;
lpbi->hwndOwner=GetSafeHwnd();//NULL;
lpbi->pidlRoot=NULL;
lpbi->pszDisplayName=NULL;
lpbi->lpszTitle="请选择要写文件的的位置:";
lpbi->ulFlags=BIF_RETURNONLYFSDIRS|BIF_STATUSTEXT;
lpbi->lpfn=NULL;
//显示外壳文件夹以便用户选择
LPITEMIDLIST lpitemidlist=SHBrowseForFolder(lpbi);
if(lpitemidlist==NULL)
{
delete lpbi;
lpbi = NULL;
return;
}
char path[MAX_PATH];
//转换项目标志符列表为一个系统文件路径
SHGetPathFromIDList(lpitemidlist,path);
delete lpbi;
m_destinationPath = path;
UpdateData(FALSE);
}
void CFileRW::Onsource()
{
// TODO: Add your control notification handler code here
//此函数用来选择源文件
CString strFilter;
strFilter="All Files(*.*)|*.*||";
CFileDialog dlg(TRUE, NULL, NULL, OFN_EXPLORER|OFN_HIDEREADONLY|
OFN_ENABLESIZING|OFN_FILEMUSTEXIST,strFilter);
dlg.m_ofn.lStructSize = sizeof(OPENFILENAME);
if(dlg.DoModal() == IDOK )
{
m_sourcePath=dlg.GetPathName();
}
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -