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

📄 chapter2_6dlg.cpp

📁 windows ce开发技巧与实例光盘代码
💻 CPP
字号:
// chapter2_6Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "chapter2_6.h"
#include "chapter2_6Dlg.h"
#include "StorageCard.h"
#include "Aygshell.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CChapter2_6Dlg dialog

CChapter2_6Dlg::CChapter2_6Dlg(CWnd* pParent /*=NULL*/)
	: CDialog(CChapter2_6Dlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CChapter2_6Dlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CChapter2_6Dlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CChapter2_6Dlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CChapter2_6Dlg, CDialog)
	//{{AFX_MSG_MAP(CChapter2_6Dlg)
	ON_BN_CLICKED(IDC_BUT_BACKUP, OnButBackup)
	ON_BN_CLICKED(IDC_BUT_RESTRORE, OnButRestrore)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CChapter2_6Dlg message handlers

BOOL CChapter2_6Dlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	CenterWindow(GetDesktopWindow());	// center to the hpc screen

	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}



void CChapter2_6Dlg::OnButBackup() 
{
	CStorageCard p;	
	POSITION pos = p.s_listStorageName.GetHeadPosition();	
	CString strPath;
	
//	CChapter2_6App* pTheApp = (CChapter2_6App*)AfxGetApp();

	if (p.s_listStorageName.GetCount() > 0)
	{
		strPath = p.s_listStorageName.GetNext(pos);		
		strPath += L"\\text.txt";
		
		if (!CopyFile(L"\\text.txt", strPath, FALSE))	//copy and overwrite
		{
			AfxMessageBox(L"备份数据失败", MB_OK | MB_ICONEXCLAMATION);				
		}	
		else
		{
			AfxMessageBox(L"备份数据成功", MB_OK | MB_ICONEXCLAMATION);				
		}
	}				
	else
	{
		AfxMessageBox(L"未找到存储卡", MB_OK | MB_ICONEXCLAMATION);				
	}
	
}

void CChapter2_6Dlg::OnButRestrore() 
{
	// TODO: Add your control notification handler code here
	CStorageCard p;	
	POSITION pos = p.s_listStorageName.GetHeadPosition();	
	CString strPath;
	
	if (p.s_listStorageName.GetCount() > 0)
	{
		strPath = p.s_listStorageName.GetNext(pos);		
		strPath += L"\\text.txt";
		
		if (!SearchDB(strPath))
		{
			AfxMessageBox(L"存储卡上没有备份数据", MB_OK | MB_ICONEXCLAMATION);				
		}
		
		if (CopyFile(strPath, L"\\text.txt", FALSE))
		{
			AfxMessageBox(L"恢复数据成功", MB_OK | MB_ICONEXCLAMATION);				
		}
		else
		{
			AfxMessageBox(L"恢复数据失败", MB_OK | MB_ICONEXCLAMATION);				
		}


	}		
	else
	{
		AfxMessageBox(L"未找到存储卡", MB_OK | MB_ICONEXCLAMATION);				
	}
	
}

BOOL CChapter2_6Dlg::SearchDB(CString strDBPathName)
{
	WIN32_FIND_DATA fd;	
	return (::FindFirstFile(strDBPathName, &fd) != INVALID_HANDLE_VALUE);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -