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

📄 ebackup2002dialog.cpp

📁 手机数据备份软件
💻 CPP
字号:
// MainWnd.cpp: implementation of the CMainWnd class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "eBackup2002Dialog.h"
#include <projects.h>
#include "SelectDatasDlg.h"
#include "ProgressDlg.h"

#include "Public.h"
#pragma comment(lib,"note_prj.lib")


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////


CeBackup2002Dialog::CeBackup2002Dialog()
{

}

CeBackup2002Dialog::~CeBackup2002Dialog()
{

}
LRESULT CeBackup2002Dialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	m_hMenuBar = CreateMenuBarWnd(m_hWnd,IDR_MAINMENU);
	CheckRadioButton(IDC_BACKUP,IDC_RESTORE,IDC_BACKUP); 
	m_BackupButton.SubclassWindow(GetDlgItem(IDC_BACKUP));
	m_BackupButton.ModifyStyle(0,BS_OWNERDRAW);
	m_RestoreButton.SubclassWindow(GetDlgItem(IDC_RESTORE));
	m_RestoreButton.ModifyStyle(0,BS_OWNERDRAW);
//	SendDlgItemMessage(IDC_RESTORE,WM_SETFOCUS,VK_TDOWN);

	//m_BackupButton.SetCheck(TRUE);
	HICON hIcon = LoadIcon(_Module.GetResourceInstance(),MAKEINTRESOURCE(IDI_BACKUP));
	SetIcon(hIcon,TRUE);
	SetIcon(hIcon,FALSE);

	for(int i = 0; i < 3 ;i++)
		m_additionalstorage[i].Empty();
	m_StorageType.Empty();

	if (FindStorage())
	{
		HMENU hPopupMenu = FindPopupMenuByMenuHwnd(m_hMenuBar,IDM_MENU);
		CString StorageStr;
		for (i = 0; i < 3; i++)
		{
			if (m_additionalstorage[i].IsEmpty())
				break;
			StorageStr.LoadString(FLASHROM_TXT);
			if (m_additionalstorage[i].Find(StorageStr) != -1)
				EnableMenuItem(hPopupMenu,IDM_CARD_FLASHROM,MF_BYCOMMAND|MF_ENABLED);
			else
			{
				StorageStr.LoadString(MMCCARD_TXT);
				if (m_additionalstorage[i].Find(StorageStr) != -1)
					EnableMenuItem(hPopupMenu,IDM_CARD_MMC,MF_BYCOMMAND|MF_ENABLED);
				else
				{
					StorageStr.LoadString(SDCARD_TXT);
					if (m_additionalstorage[i].Find(StorageStr) != -1)
						EnableMenuItem(hPopupMenu,IDM_CARD_SD,MF_BYCOMMAND|MF_ENABLED);				
				}
			}
//			AppendMenu(hPopupMenu,MF_STRING,IDM_LAST,m_additionalstorage[i]);
		}		
	}
	else
		EnableToolBarMenuItem(m_hMenuBar,IDM_MENU,FALSE);
		
	HMENU hPopupMenu = FindPopupMenuByMenuHwnd(m_hMenuBar,IDM_MENU);
	CheckMenuRadioItem(hPopupMenu,IDM_CARD_SD,IDM_CARD_FLASHROM,IDM_CARD_FLASHROM,MF_BYCOMMAND);
	m_StorageType.LoadString(FLASHROM_TXT);
	return 0;
}

LRESULT CeBackup2002Dialog::OnCancel(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	EndDialog(IDCANCEL);  
	return 0;
}

LRESULT CeBackup2002Dialog::OnNext(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
	HMENU hPopupMenu = FindPopupMenuByMenuHwnd(m_hMenuBar,IDM_MENU);
	//if no storage was found, return
	if (!FindStorage())
	{
		CString Msg,War;
		Msg.LoadString(MSG_NOSTORAGE);
		War.LoadString(WARNING_TXT);
		MessageBox(Msg,War,MB_OK|MB_ICONSTOP);
		CheckMenuRadioItem(hPopupMenu,IDM_CARD_SD,IDM_CARD_FLASHROM,IDM_CARD_FLASHROM,MF_BYCOMMAND);
		return 0;
	}
	else
	{
		BOOL FindFlag = FALSE;
		for(int i = 0 ;i < 3 ;i++)
		{
			if (m_additionalstorage[i].IsEmpty())
				break;
			if (m_additionalstorage[i].Find(m_StorageType) != -1)
			{
				FindFlag = TRUE;
				break;
			}
		}
		if (!FindFlag)
		{
			CString Msg,War;
			Msg.Format(MSG_MEDIAERROR,m_StorageType);
			War.LoadString(WARNING_TXT);
			MessageBox(Msg,War,MB_OK | MB_ICONWARNING);
			CheckMenuRadioItem(hPopupMenu,IDM_CARD_SD,IDM_CARD_FLASHROM,IDM_CARD_FLASHROM,MF_BYCOMMAND);
			return 0;
		}
	}
	
	//Backup or Restore
	
	if (m_BackupButton.GetCheck())
	{
		CString Msg;
		Msg.Format(MSG_STORAGESELECT,m_StorageType);
		if (MessageBox(Msg,NULL,MB_YESNO | MB_ICONINFORMATION) == IDNO)
		{
			m_StorageType.LoadString(FLASHROM_TXT);
//			m_SelectedStr = L"Flash";
			CheckMenuRadioItem(hPopupMenu,IDM_CARD_SD,IDM_CARD_FLASHROM,IDM_CARD_FLASHROM,MF_BYCOMMAND);
			return 0;
		}
		m_StorageType = L"\\" + m_StorageType + L"\\";
		
		CSelectDatasDlg dlg;
		dlg.m_StorageType = m_StorageType;
		dlg.DoModal();
	}
	else
	{
		CString Msg,War;
		if (!m_RestoreButton.GetCheck())
		{
			Msg.LoadString(MSG_NOSELECTEDOP);
			War.LoadString(WARNING_TXT);
			MessageBox(Msg,War,MB_OK | MB_ICONINFORMATION);
			return 0;
		}
		
		Msg.Format(MSG_SELECTRESTORE,m_StorageType);
		if (MessageBox(Msg,NULL,MB_YESNO | MB_ICONINFORMATION) == IDNO)
		{
			m_StorageType.LoadString(FLASHROM_TXT);
//			m_SelectedStr = L"Flash";
			CheckMenuRadioItem(hPopupMenu,IDM_CARD_SD,IDM_CARD_FLASHROM,IDM_CARD_FLASHROM,MF_BYCOMMAND);
			return 0;
		}
		m_StorageType = L"\\" + m_StorageType + L"\\";
		CProgressDlg dlg;
		dlg.m_StorageType = m_StorageType;
		dlg.m_BackupFlag = FALSE;
		dlg.DoModal();
	}
	m_StorageType.LoadString(FLASHROM_TXT);
//	m_SelectedStr = L"Flash";
	CheckMenuRadioItem(hPopupMenu,IDM_CARD_SD,IDM_CARD_FLASHROM,IDM_CARD_FLASHROM,MF_BYCOMMAND);
	return 0;
}

LRESULT CeBackup2002Dialog::OnStoreCard(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
    //add your code here ,where wID is ID 
	HMENU hPopupMenu = FindPopupMenuByMenuHwnd(m_hMenuBar,IDM_MENU);	
	CheckMenuRadioItem(hPopupMenu,IDM_CARD_SD,IDM_CARD_FLASHROM,wID,MF_BYCOMMAND);
	switch (wID)
	{
	case IDM_CARD_FLASHROM:
		m_StorageType.LoadString(FLASHROM_TXT);
		break;
	case IDM_CARD_MMC:
		m_StorageType.LoadString(MMCCARD_TXT);	
		break;
	case IDM_CARD_SD:
		m_StorageType.LoadString(SDCARD_TXT);
	}
	return 0;
}
LRESULT CeBackup2002Dialog::OnKeyDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	// TODO : Add Code for message handler. Call DefWindowProc if necessary.
	bHandled = FALSE;
	return 0;
}
//////////////////////////////////////////////////////////////////
// find Storage Card and Flash Rom 
// RETURN VALUE: 
//     TRUE if Get one successfully,otherwise FALSE
// AUTOTHOR: sunyh
// VERSION: 1.0        
//////////////////////////////////////////////////////////////////
BOOL CeBackup2002Dialog::FindStorage()
{
	// Search handle for storage cards.
	HANDLE hFlashCard;  
	// Structure for storing storage
	WIN32_FIND_DATA *lpwfdFlashCardTmp; 
    // card information temporarily.
	lpwfdFlashCardTmp = (WIN32_FIND_DATA *) LocalAlloc (LPTR, 10 * sizeof (WIN32_FIND_DATA));
	// Failed allocate memory return;
	if (lpwfdFlashCardTmp == NULL)      
		return FALSE;
	
	//init the string array
	for(int j = 0; j < 3 ;j++)
		m_additionalstorage[j].Empty();
	//Find all flash card and add their name to string array
	hFlashCard = FindFirstFlashCard(&lpwfdFlashCardTmp [0]);

  	if(hFlashCard == INVALID_HANDLE_VALUE)
		return FALSE;		
	int i = 0;
	m_additionalstorage[i++] = lpwfdFlashCardTmp->cFileName;
	
	while(FindNextFlashCard(hFlashCard,&lpwfdFlashCardTmp[0]))
		m_additionalstorage[i++] = lpwfdFlashCardTmp->cFileName;

	return TRUE;
}
LRESULT CeBackup2002Dialog::OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	// TODO : Add Code for message handler. Call DefWindowProc if necessary.
	CPaintDC dc(m_hWnd);
	CPen pen;
	pen.CreatePen(PS_SOLID,2,RGB(0,0,0));
	::SelectObject(dc.m_hDC,pen);
	CRect rect;
	GetClientRect(&rect);
	rect.DeflateRect(20,20,20,40);	
	dc.Draw3dRect(rect,RGB(0,0,0),GetSysColor(COLOR_3DFACE));//RGB(210,210,210));
	rect.InflateRect(1,1,1,1);
	dc.Draw3dRect(rect,RGB(70,70,70),RGB(200,200,200));
	rect.InflateRect(2,2,2,2);
	dc.Draw3dRect(rect,RGB(0,0,0),RGB(0,0,0));
	return 0;
}

⌨️ 快捷键说明

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