?? 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
//聲明一個文件夾瀏覽結(jié)構(gòu)
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];
//轉(zhuǎn)換項目標志符列表為一個系統(tǒng)文件路徑
SHGetPathFromIDList(lpitemidlist,path);
delete lpbi;
m_destinationPath = path;
UpdateData(FALSE);
}
void CFileRW::Onsource()
{
// TODO: Add your control notification handler code here
//此函數(shù)用來選擇源文件
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);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -