📄 backup.cpp
字号:
// Backup.cpp : implementation file
//
#include "stdafx.h"
#include "Capture.h"
#include "Backup.h"
#include "DataManage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define WM_NOMAL WM_USER+101
#define WM_BACKUP WM_USER+102
#define WM_QUITAPP WM_USER+103
CEvent CBackup::s_normal;
HWND CBackup::s_hWnd;
CWinThread * pthread;
BOOL terminated = false;
/////////////////////////////////////////////////////////////////////////////
// CBackup dialog
extern CDataManage dataManage;
CBackup::CBackup(CWnd* pParent /*=NULL*/)
: CDialog(CBackup::IDD, pParent)
{
//{{AFX_DATA_INIT(CBackup)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CBackup::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBackup)
DDX_Control(pDX, IDC_EDIT1, m_dir);
DDX_Control(pDX, IDC_PROGRESS1, m_progress);
DDX_Control(pDX, IDC_BUTTONBROUWN, m_brown);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBackup, CDialog)
//{{AFX_MSG_MAP(CBackup)
ON_MESSAGE(WM_NOMAL,OnNomal)
ON_MESSAGE(WM_QUITAPP,OnQuit)
ON_BN_CLICKED(IDC_BUTTONBACKUP, OnButtonbackup)
ON_BN_CLICKED(IDC_BUTTONCANCEL, OnButtoncancel)
ON_MESSAGE(WM_BACKUP,OnBackup)
ON_BN_CLICKED(IDC_BUTTONBROUWN, OnButtonbrouwn)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBackup message handlers
void CBackup::OnOK()
{
// TODO: Add extra validation here
}
void CBackup::OnButtonbackup()
{
CString m_filename;
m_dir.GetWindowText(m_filename);
if (! m_filename.IsEmpty())
{
CString sql;
sql.Format("backup database DB_Capture to disk = '%s'",m_filename);
try
{
dataManage.p_Con->Execute((_bstr_t)sql,NULL,adCmdText);
// s_hWnd = this->GetSafeHwnd();
// pthread = AfxBeginThread(DoBackup,s_hWnd);
MessageBox("备份成功.","提示");
}
catch(_com_error &e)
{
MessageBox(e.Description());
}
}
else
MessageBox("请输入备份文件.");
}
void CBackup::OnButtoncancel()
{
EndDialog(0);
}
void CBackup::OnNomal()
{
m_progress.StepIt();
m_progress.SetPos(m_progress.GetPos()+1);
if (m_progress.GetPos()>=100)
{
s_hWnd = 0;
s_normal.SetEvent();
//AfxEndThread(0,true);
}
}
UINT CBackup::DoBackup(LPVOID pParam)
{
while( WaitForSingleObject(s_hWnd,0)!=WAIT_OBJECT_0)
{
::SendMessage(CBackup::s_hWnd,WM_NOMAL,NULL,NULL);
//::SendMessage(CBackup::s_hWnd,WM_BACKUP,0,0);
}
::PostMessage(CBackup::s_hWnd,WM_QUITAPP,0,0);
// delete pthread;
//AfxEndThread(0);
return 0;
}
BOOL CBackup::OnInitDialog()
{
CDialog::OnInitDialog();
m_progress.SetRange(0,100);
m_progress.SetStep(1);
return TRUE;
}
void CBackup::OnBackup()
{
}
void CBackup::OnButtonbrouwn()
{
CFileDialog m_file(false,"bak","Capture");
if (m_file.DoModal()==IDOK)
{
CString temp = m_file.GetPathName();
m_dir.SetWindowText(temp);
}
}
void CBackup::OnQuit()
{
//pthread->ResumeThread();
TerminateThread(*pthread,0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -