?? restoredialog.cpp
字號:
// RestoreDialog.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "RestoreDialog.h"
#include "SQLCEDemo.h"
#include "StorageCard.h"
#include "SyncView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRestoreDialog dialog
CRestoreDialog::CRestoreDialog(CWnd* pParent /*=NULL*/)
: CDialog(CRestoreDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(CRestoreDialog)
m_sta_Restore = _T("");
//}}AFX_DATA_INIT
}
void CRestoreDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRestoreDialog)
DDX_Control(pDX, IDC_BUT_RESTORE, m_btn_Restore);
DDX_Text(pDX, IDC_STATIC_RESTORE, m_sta_Restore);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRestoreDialog, CDialog)
//{{AFX_MSG_MAP(CRestoreDialog)
ON_BN_CLICKED(IDC_BUT_RESTORE, On_ButRestore)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRestoreDialog message handlers
void CRestoreDialog::On_ButRestore()
{
CWaitCursor waitcursor;
CStorageCard p;
POSITION pos = p.s_listStorageName.GetHeadPosition();
CString strPath;
if (p.s_listStorageName.GetCount() > 0)
{
strPath = p.s_listStorageName.GetNext(pos);
strPath += L"\\palmheart.sdf";
if (!CSyncView::SearchDB(strPath))
{
AfxMessageBox(L"存儲卡上沒有備份數據", MB_OK | MB_ICONEXCLAMATION);
}
if (CopyFile(strPath, L"\\palmheart.sdf", FALSE))
{
AfxMessageBox(L"恢復數據成功", MB_OK | MB_ICONEXCLAMATION);
}
else
{
AfxMessageBox(L"恢復數據失敗", MB_OK | MB_ICONEXCLAMATION);
}
}
else
{
AfxMessageBox(L"未找到存儲卡", MB_OK | MB_ICONEXCLAMATION);
}
waitcursor.Restore();
}
void CRestoreDialog::OnPaint()
{
CPaintDC dc(this); // device context for painting
WIN32_FIND_DATA fd;
HANDLE hFind;
CFile nFile;
hFind=::FindFirstFile(_T("\\SD Card\\palmheart.sdf"), &fd);
if (hFind == INVALID_HANDLE_VALUE) {
m_btn_Restore.EnableWindow(FALSE);
m_sta_Restore=L"說明:\n 存儲卡不存在或者存儲卡中不存在備份文件。";
UpdateData(FALSE);
}
else
{
m_btn_Restore.EnableWindow(TRUE);
m_sta_Restore=L"說明:\n 將數據從存儲卡中恢復到PDA中,PDA中原有數據將被覆蓋。";
UpdateData(FALSE);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -