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

📄 mainfrm.cpp

📁 一个农用车辆管理系统的雏形
💻 CPP
字号:
// MainFrm.cpp : CMainFrame 类的实现
//

#include "stdafx.h"
#include "NongCheManage.h"

#include "MainFrm.h"
#include ".\mainfrm.h"

#include "IndexDataSet.h"
#include "UserManage.h"
#include "SystemReg.h"
#include "BakcupDatabase.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CMainFrame

IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
	ON_WM_CREATE()
	// 全局帮助命令
	ON_COMMAND(ID_HELP_FINDER, CMDIFrameWnd::OnHelpFinder)
	ON_COMMAND(ID_HELP, CMDIFrameWnd::OnHelp)
	ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp)
	ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpFinder)
	ON_COMMAND(ID_INDEXDATASET, OnIndexdataset)
	ON_COMMAND(ID_USERSET, OnUserset)
	ON_COMMAND(ID_OTHERSET, OnOtherset)
	ON_COMMAND(ID_LOCKSYSTEM, OnLocksystem)
	ON_COMMAND(ID_EXITSYSTEM, OnExitsystem)
	ON_COMMAND(ID_INPUTCHEDATA, OnInputchedata)
	ON_COMMAND(ID_QUERYCEI, OnQuerycei)
	ON_COMMAND(ID_PRINT1TEXT, OnPrint1text)
	ON_COMMAND(ID_PRINT2TEXT, OnPrint2text)
	ON_COMMAND(ID_PRINT3TEXT, OnPrint3text)
	ON_COMMAND(ID_EXCEL1TEXT, OnExcel1text)
	ON_COMMAND(ID_EXCEL2TEXT, OnExcel2text)
	ON_COMMAND(ID_EXCEL3TEXT, OnExcel3text)
	ON_COMMAND(ID_BACKUPDATABASE, OnBackupdatabase)
	ON_COMMAND(ID_RESTORDATABASE, OnRestordatabase)
	ON_COMMAND(ID_DELDATA, OnDeldata)
	ON_COMMAND(ID_INPUTREGFILE, OnInputregfile)
	ON_COMMAND(ID_SYSTEMREG, OnSystemreg)
	ON_WM_SIZE()
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // 状态行指示器
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};


// CMainFrame 构造/析构

CMainFrame::CMainFrame()
{
	EnableActiveAccessibility();
	pDoc1=NULL;
	pDoc2=NULL;
	pDoc3=NULL;
}

CMainFrame::~CMainFrame()
{
}


int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("未能创建状态栏\n");
		return -1;      // 未能创建
	}

	ASSERT(m_hWndMDIClient!=NULL);
	if (!m_bgcolorwnd.SubclassWindow(m_hWndMDIClient))
		return -1;

	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CMDIFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
	// 样式

	//cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
	//	 | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_MAXIMIZE | WS_SYSMENU;

	return TRUE;
}


// CMainFrame 诊断

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CMDIFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CMDIFrameWnd::Dump(dc);
}

#endif //_DEBUG


// CMainFrame 消息处理程序


void CMainFrame::OnIndexdataset()//初始化数据
{
	CIndexDataSet dlg;
	dlg.DoModal();
}

void CMainFrame::OnUserset()//用户管理
{
	CUserManage dlg;
	dlg.DoModal();
}

void CMainFrame::OnOtherset()//其它设置
{
	// TODO: 在此添加命令处理程序代码
}

void CMainFrame::OnLocksystem()//锁定系统
{
	// TODO: 在此添加命令处理程序代码
}

void CMainFrame::OnExitsystem()//退出系统
{
	// TODO: 在此添加命令处理程序代码
}

void CMainFrame::OnInputchedata()//车辆档案录入
{
	if(pDoc2==NULL)
	{
		CNongCheManageApp * pmdisdiapp =(CNongCheManageApp *)AfxGetApp();
		pDoc2=(CInputDoc *)pmdisdiapp->pDoctemp2->OpenDocumentFile(NULL);
	}
	else
	{
		POSITION pos;
		pos=pDoc2->GetFirstViewPosition();
		CView * pView;
		pView=pDoc2->GetNextView(pos);
		pView->GetParentFrame()->ActivateFrame();
	}
}

void CMainFrame::OnQuerycei()//查询所有车辆及驾驶证
{
	if(pDoc3==NULL)
	{
		CNongCheManageApp * pmdisdiapp =(CNongCheManageApp *)AfxGetApp();
		pDoc3=(CQueryDoc *)pmdisdiapp->pDoctemp3->OpenDocumentFile(NULL);
	}
	else
	{
		POSITION pos;
		pos=pDoc3->GetFirstViewPosition();
		CView * pView;
		pView=pDoc3->GetNextView(pos);
		pView->GetParentFrame()->ActivateFrame();
	}
}

void CMainFrame::OnPrint1text()//打印登记证书
{
	theApp.pringtext=1;
	if(pDoc1==NULL)
	{
		CNongCheManageApp * pmdisdiapp =(CNongCheManageApp *)AfxGetApp();
		pDoc1=(CNongCheManageDoc *)pmdisdiapp->pDoctemp1->OpenDocumentFile(NULL);
	}
	else
	{
		POSITION pos;
		pos=pDoc1->GetFirstViewPosition();
		CView * pView;
		pView=pDoc1->GetNextView(pos);
		pView->GetParentFrame()->ActivateFrame();
	}
}

void CMainFrame::OnPrint2text()//打印行驶证
{
	theApp.pringtext=2;
	if(pDoc1==NULL)
	{
		CNongCheManageApp * pmdisdiapp =(CNongCheManageApp *)AfxGetApp();
		pDoc1=(CNongCheManageDoc *)pmdisdiapp->pDoctemp1->OpenDocumentFile(NULL);
	}
	else
	{
		POSITION pos;
		pos=pDoc1->GetFirstViewPosition();
		CView * pView;
		pView=pDoc1->GetNextView(pos);
		pView->GetParentFrame()->ActivateFrame();
	}
}

void CMainFrame::OnPrint3text()//打印行驶证副页
{
	theApp.pringtext=3;
	if(pDoc1==NULL)
	{
		CNongCheManageApp * pmdisdiapp =(CNongCheManageApp *)AfxGetApp();
		pDoc1=(CNongCheManageDoc *)pmdisdiapp->pDoctemp1->OpenDocumentFile(NULL);
	}
	else
	{
		POSITION pos;
		pos=pDoc1->GetFirstViewPosition();
		CView * pView;
		pView=pDoc1->GetNextView(pos);
		pView->GetParentFrame()->ActivateFrame();
	}
}

void CMainFrame::OnExcel1text()//导出登记证书至EXCEL
{
	// TODO: 在此添加命令处理程序代码
}

void CMainFrame::OnExcel2text()//导出行驶证至EXCEL
{
	// TODO: 在此添加命令处理程序代码
}

void CMainFrame::OnExcel3text()//导出行驶证副页至EXCEL
{
	// TODO: 在此添加命令处理程序代码
}

void CMainFrame::OnBackupdatabase()//备份数据
{
	CBakcupDatabase dlg;
	dlg.m_type=true;//备份,默认false为恢复
	dlg.DoModal();
}

void CMainFrame::OnRestordatabase()//恢复数据
{
	CBakcupDatabase dlg;
	dlg.DoModal();
}

void CMainFrame::OnDeldata()//批量删除数据
{
	// TODO: 在此添加命令处理程序代码
}

void CMainFrame::OnInputregfile()//导入注册文件
{
	// TODO: 在此添加命令处理程序代码
}

void CMainFrame::OnSystemreg()//软件注册
{
	CSystemReg dlg;
	dlg.DoModal();
}

BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
	if(pMsg->hwnd==m_hWndMDIClient && pMsg->message==WM_PAINT)
		PostMessage(WM_PAINT);

	return CMDIFrameWnd::PreTranslateMessage(pMsg);
}

void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
	CMDIFrameWnd::OnSize(nType, cx, cy);

	Invalidate(TRUE);
}

⌨️ 快捷键说明

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