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

📄 importdlg.cpp

📁 用Visual C++ 开发的项目管理系统
💻 CPP
字号:
// ImportDlg.cpp : implementation file
//

#include "stdafx.h"
#include "FileMaSys.h"
#include "ImportDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CImportDlg dialog


CImportDlg::CImportDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CImportDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CImportDlg)
	m_cDBPathFrom = _T("");
	//}}AFX_DATA_INIT
}


void CImportDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CImportDlg)
	DDX_Control(pDX, IDCANCEL, m_BtnExit);
	DDX_Control(pDX, IDC_BTN_OPENDLG, m_BtnOpenDlg);
	DDX_Control(pDX, IDC_BTN_IMPORT, m_BtnImport);
	DDX_CBString(pDX, IDC_COMBO_DBPATH, m_cDBPathFrom);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CImportDlg, CDialog)
	//{{AFX_MSG_MAP(CImportDlg)
	ON_BN_CLICKED(IDC_BTN_OPENDLG, OnBtnOpendlg)
	ON_BN_CLICKED(IDC_BTN_IMPORT, OnBtnImport)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CImportDlg message handlers

void CImportDlg::OnBtnOpendlg() 
{
	// TODO: Add your control notification handler code here
	CFileDialog filedlg(TRUE);
	filedlg.m_ofn.lStructSize=sizeof(OPENFILENAME);
	filedlg.m_ofn.lpstrFilter="All Files\0*.*\0mdb File\0*.mdb\0\0";
	filedlg.m_ofn.nFilterIndex=2;
	filedlg.m_ofn.lpstrInitialDir="D:\\DBbackup";
	filedlg.m_ofn.lpstrTitle="选择数据库文件";
	if (filedlg.DoModal()==IDOK)
	{
         m_cDBPathFrom=filedlg.GetPathName();
		 UpdateData(FALSE);
	}
}

void CImportDlg::OnBtnImport() 
{
	// TODO: Add your control notification handler code here
	//导入的绝对路径
	CHAR exePath[MAX_PATH];
	GetModuleFileName(NULL,exePath,MAX_PATH);
	CString StartPath;
	StartPath=exePath;
	int index=StartPath.ReverseFind('\\');
	index++;
	StartPath=StartPath.Left(index);
	m_cDBPathTo=StartPath+"ProjectManageSys.mdb";
	//覆盖已有文件
	if (CopyFile(m_cDBPathFrom,m_cDBPathTo,FALSE))
	{
		MessageBox("导入成功");
	}
	else
	{
		MessageBox("导入失败");
	}

}

BOOL CImportDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	HICON iconExit=(HICON)LoadImage(AfxGetApp()->m_hInstance,MAKEINTRESOURCE(IDI_ICON_ERROR),
		IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
	//设置退出按钮
	m_BtnExit.SetIcon(iconExit);
	m_BtnExit.DrawTransparent(TRUE);
	m_BtnExit.SetColor(CButtonST::BTNST_COLOR_FG_IN,RGB(255,0,0));
	m_BtnExit.SetAlign(CButtonST::ST_ALIGN_HORIZ);
	//设置导入数据库按钮
	m_BtnImport.SetIcon(IDI_ICON_RETURN);
	m_BtnImport.DrawTransparent(TRUE);
	m_BtnImport.SetColor(CButtonST::BTNST_COLOR_FG_IN,RGB(255,0,0));
	m_BtnImport.SetAlign(CButtonST::ST_ALIGN_HORIZ);
	//设置浏览文件夹按钮
    m_BtnOpenDlg.SetIcon(IDI_ICON_FOLDER);
	m_BtnOpenDlg.DrawTransparent(TRUE);
	m_BtnOpenDlg.SetColor(CButtonST::BTNST_COLOR_FG_IN,RGB(255,0,0));
	m_BtnOpenDlg.SetAlign(CButtonST::ST_ALIGN_HORIZ);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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