⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 restoredialog.cpp

📁 WinCE开发技巧与实例的配套源码
💻 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 + -