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

📄 dialog6.cpp

📁 自己 写的 玩下 还有 很多 功能要 大家一起 开发
💻 CPP
字号:
// Dialog6.cpp : implementation file
//

#include "stdafx.h"
#include "图书管理系统.h"
#include "Dialog6.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDialog6 dialog


CDialog6::CDialog6(CWnd* pParent /*=NULL*/)
	: CDialog(CDialog6::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDialog6)
	m_name = _T("");
	m_cipan = _T("");
	//}}AFX_DATA_INIT
}


void CDialog6::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDialog6)
	DDX_Control(pDX, IDC_TREE, m_Tree);
	DDX_Text(pDX, IDC_NAME, m_name);
	DDX_Text(pDX, IDC_CIPAN, m_cipan);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDialog6, CDialog)
	//{{AFX_MSG_MAP(CDialog6)
	ON_BN_CLICKED(IDC_BTN_REDE, OnBtnRede)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDialog6 message handlers

BOOL CDialog6::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	 HTREEITEM faItem=NULL;
	AddFile(m_cipan,faItem);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDialog6::OnBtnRede() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_cipan=="")
	{
		AfxMessageBox("请输入磁盘名!");
		return;
	}
	if(m_name=="")
	{
		AfxMessageBox("输入备分的文件名");
		return;
	}
	HTREEITEM faItem=NULL;
	m_Tree.UpdateWindow();
	AddFile(m_cipan,faItem);
    int i=	m_cipan.GetLength();
	char *buffer=(char*)(LPCSTR)m_cipan;
     if(buffer[i-2]==':')
	 {
     CopyFile(m_cipan+"\\"+m_name+".mdb","Book.mdb",TRUE);
   
	 }	
   else
    CopyFile(m_cipan+":\\"+m_name+".mdb","Book.mdb",TRUE);
   AfxMessageBox("恢复文件成功");
    
}

void CDialog6::AddFile(CString StrPath, HTREEITEM faItem)
{
 CFileFind OneFile;
 CString FName, DirName;
 BOOL BeWorking; 
 HTREEITEM NewItem; 

 DirName = StrPath+"\\*.*";
 BeWorking = OneFile.FindFile(DirName );
 while ( BeWorking ) {    //BeWorking非零,指找了文件或目录

  //查找同级的目录
  BeWorking = OneFile.FindNextFile();

  if ( OneFile.IsDirectory() && !OneFile.IsDots() )        //如果查找的结果是目录又不是".."或"."
  { 
   //向Tree1中添加目录;
   DirName = OneFile.GetFilePath();
   FName = OneFile.GetFileTitle(); 
   //IDC_TREE1
   NewItem = m_Tree.InsertItem( FName, faItem );    //NewItem取得节点,其目的是为了下一层中
          //添加节点方便,递归时把它传过去。
   //进入下一层递归调用。
   AddFile(DirName, NewItem);
  }

  //退出递归时,到了这里!!!
  if ( !OneFile.IsDirectory() && !OneFile.IsDots() )       //如果查找结果是文件
  {
   //向Tree1中添加文件
   FName = OneFile.GetFileTitle();    //注意这里用的是GetFileTitle,因为
          //这里是添加文件。
   m_Tree.InsertItem( FName, faItem );
  }

  
 }// end of while
 
 OneFile.Close();
}

HBRUSH CDialog6::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	// TODO: Change any attributes of the DC here
	if(nCtlColor==CTLCOLOR_LISTBOX)
	{
		//pDC->SetBkMode(TRANSPARENT);
		pDC->SetTextColor(RGB(0,0,0));
		pDC->SetBkColor(RGB(233,233,220));
		HBRUSH b=CreateSolidBrush(RGB(233,233,220));
		return b;
	}
	else if(nCtlColor==CTLCOLOR_SCROLLBAR)
	{
		//pDC->SetBkMode(TRANSPARENT);
		pDC->SetTextColor(RGB(0,0,0));
		pDC->SetBkColor(RGB(233,233,220));
		HBRUSH b=CreateSolidBrush(RGB(233,233,220));
		return b;
	}
	else if(nCtlColor==CTLCOLOR_EDIT)
	{
		//pDC->SetBkMode(TRANSPARENT);
		pDC->SetTextColor(RGB(0,0,0));
		pDC->SetBkColor(RGB(233,233,220));
		HBRUSH b=CreateSolidBrush(RGB(233,233,220));
		return b;
	}
	else if(nCtlColor==CTLCOLOR_STATIC)
	{
		pDC->SetTextColor(RGB(0,0,0));
		pDC->SetBkColor(RGB(160,180,220));
		HBRUSH b=CreateSolidBrush(RGB(160,180,220));
		return b;
	}
	else if(nCtlColor==CTLCOLOR_DLG)
	{
		pDC->SetTextColor(RGB(0,0,0));
		pDC->SetBkColor(RGB(160,180,220));
		HBRUSH b=CreateSolidBrush(RGB(160,180,220));
		return b;
	}
	
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

⌨️ 快捷键说明

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