📄 copydata.cpp
字号:
// CopyData.cpp : implementation file
//
#include "stdafx.h"
#include "DataBaseSoftWare.h"
#include "CopyData.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _RecordsetPtr m_pRecordset;
extern CDataBaseSoftWareApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CopyData dialog
CopyData::CopyData(CWnd* pParent /*=NULL*/)
: CDialog(CopyData::IDD, pParent)
{
//{{AFX_DATA_INIT(CopyData)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
isFirst=0;
}
void CopyData::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CopyData)
DDX_Control(pDX, IDC_BTSET, m_set);
DDX_Control(pDX, IDC_BTEXIT, m_exit);
DDX_Control(pDX, IDC_BTADD, m_save);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CopyData, CDialog)
//{{AFX_MSG_MAP(CopyData)
ON_BN_CLICKED(IDC_BTADD, OnBtadd)
ON_BN_CLICKED(IDC_BTEXIT, OnBtexit)
ON_BN_CLICKED(IDC_BTSET, OnBtset)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CopyData message handlers
void CopyData::OnBtadd()
{
// TODO: Add your control notification handler code here
CFileDialog log(FALSE ,"文件","*.mdb",OFN_HIDEREADONLY,
"数据库文件(*.mdb)|*.ldb||",NULL);
if(log.DoModal()==IDOK)
{
// 实现存盘
fileName= log.GetPathName();
GetDlgItem(IDC_EDSOUND)->SetWindowText(fileName);
if(isFirst==0)
{
::WriteProfileString("Path","admin",fileName);
isFirst=1;
}
// bSave = TRUE;
// m_sFileName = fileName;
}
}
void CopyData::OnBtexit()
{
// TODO: Add your control notification handler code here
this->OnCancel();
}
void CopyData::OnBtset()
{
// TODO: Add your control notification handler code here
CString name;
GetDlgItem(IDC_BTSET)->GetWindowText(name);
CString sound;
char temp[50],paths[50];
for(int j=0;j<50;j++)
{
paths[j]=NULL;
}
strcpy(temp,sound);
GetDlgItem(IDC_EDSOUND)->GetWindowText(temp,50);
int pj=0;
int plength=strlen(temp);
for(int i=0;i<plength;i++)
{
if(temp[i]!=92)
{
paths[pj]=temp[i];
pj++;
}
else
{
paths[pj]=temp[i];
paths[++pj]=temp[i];
pj++;
}
}
GetDlgItem(IDC_EDSOUND)->GetWindowText(fileName);
if(CopyFile("name.mdb",fileName,FALSE))
AfxMessageBox("数据库备份成功!");
else
AfxMessageBox("数据库备份失败!");
this->OnCancel();
}
BOOL CopyData::OnInitDialog()
{
CDialog::OnInitDialog();
CString strPath;
::GetProfileString("Path","admin","paths" ,
strPath.GetBuffer(100),100);
CString temp;
GetDlgItem(IDC_EDSOUND)->GetWindowText(temp);
if(!temp.IsEmpty())
GetDlgItem(IDC_EDSOUND)->SetWindowText(temp);
else
GetDlgItem(IDC_EDSOUND)->SetWindowText(strPath);
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -