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

📄 dialog5.cpp

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CDialog5 dialog


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


void CDialog5::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDialog5)
	DDX_Control(pDX, IDC_MSGLIST, m_Tree);
	DDX_Text(pDX, IDC_NAME, m_filename);
	DDX_Text(pDX, IDC_CIPAN, m_cipan);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDialog5, CDialog)
	//{{AFX_MSG_MAP(CDialog5)
	ON_BN_CLICKED(IDC_BTN_SAVE, OnBtnSave)
	ON_EN_CHANGE(IDC_CIPAN, OnChangeCipan)
	ON_EN_CHANGE(IDC_NAME, OnChangeName)
	ON_WM_CTLCOLOR()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDialog5 message handlers

void CDialog5::OnBtnSave() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_cipan=="")
	{
		AfxMessageBox("请输入磁盘名!");
		return;
	}
	if(m_filename=="")
	{
		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("Book.mdb",m_cipan+"\\"+m_filename+".mdb",TRUE);
   
	 }	
   else
    CopyFile("Book.mdb",m_cipan+":\\"+m_filename+".mdb",TRUE);
   AfxMessageBox("备分文件成功");
    
}



void CDialog5::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();
}

BOOL CDialog5::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 CDialog5::OnChangeCipan() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
/*	UpdateData();
	HTREEITEM faItem;
	AddFile(m_cipan,faItem);*/
	// TODO: Add your control notification handler code here
	
}

void CDialog5::OnChangeName() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
/*		UpdateData();
	HTREEITEM faItem;
	AddFile(m_cipan,faItem);*/
	// TODO: Add your control notification handler code here
	
}

HBRUSH CDialog5::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 + -