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

📄 mainfrm.cpp

📁 体育信息管理系统
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "ooo.h"

#include "MainFrm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_COMMAND(ID_FILE_NEW, OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
	ON_COMMAND(ID_MENUITEM32774, OnMenuitem32774)
	ON_COMMAND(ID_MENUITEM32775, OnMenuitem32775)
	ON_COMMAND(ID_MENUITEM32776, OnMenuitem32776)
	ON_COMMAND(ID_MENUITEM32777, OnMenuitem32777)
	ON_COMMAND(ID_MENUITEM32778, OnMenuitem32778)
	ON_UPDATE_COMMAND_UI(ID_MENUITEM32777, OnUpdateMenuitem32777)
	ON_UPDATE_COMMAND_UI(ID_FILE_NEW, OnUpdateFileNew)
	ON_UPDATE_COMMAND_UI(ID_FILE_OPEN, OnUpdateFileOpen)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};
extern COooApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);

	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CMDIFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	cs.cx=800;cs.cy=600;
	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

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

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

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers


void CMainFrame::OnFileNew() 
{CNEW m_c;
COooApp*pp=(COooApp*)AfxGetApp();
if(m_c.DoModal()==IDOK){
	if(m_c.gread==0){MessageBox("请选择年级!");return;}
	if(m_c.m_file==""){MessageBox("必须输入文件名!");return;}
CString str;
if(m_c.m_path.Right(1)=="\\"){str=m_c.m_path+m_c.m_file;}
else {str=m_c.m_path+"\\"+m_c.m_file;}
pp->gread=m_c.gread;
if(pp->gread==1)
{if(!CopyFile("C:\\windows\\ty",str+".o",true)){MessageBox("同名文件已经存在,请重新输入文件名!");return;}
pp->str=str+".o";}
if(pp->gread==2)
{if(!CopyFile("C:\\windows\\ty",str+".p",true)){MessageBox("同名文件已经存在,请重新输入文件名!");return;}
pp->str=str+".p";}
if(pp->gread==3)
{if(!CopyFile("C:\\windows\\ty",str+".q",true)){MessageBox("同名文件已经存在,请重新输入文件名!");return;}
pp->str=str+".q";}
if(pp->gread==4)
{if(!CopyFile("C:\\windows\\ty",str+".r",true)){MessageBox("同名文件已经存在,请重新输入文件名!");return;}
pp->str=str+".r";}
if(pp->gread==5)
{if(!CopyFile("C:\\windows\\ty",str+".s",true)){MessageBox("同名文件已经存在,请重新输入文件名!");return;}
pp->str=str+".s";}
ab(pp->pDocTemplate);
}
else 
return;	
}

void CMainFrame::OnFileOpen() 
{SetDatabasePath("");
CFileDialog dlg(TRUE,"","",OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,0,this);
if(dlg.DoModal()==IDOK){
if(dlg.GetPathName().Right(1)!='o'&&dlg.GetPathName().Right(1)!='p'&&dlg.GetPathName().Right(1)!='q'&&dlg.GetPathName().Right(1)!='r'&&dlg.GetPathName().Right(1)!='s'){AfxMessageBox("文件类型错误!");return;}
COooApp*pp=(COooApp*)::AfxGetApp();
pp->str=dlg.GetPathName();
if(pp->str.Right(1)=='o'){pp->gread=1;}
if(pp->str.Right(1)=='p'){pp->gread=2;}
if(pp->str.Right(1)=='q'){pp->gread=3;}
if(pp->str.Right(1)=='r'){pp->gread=4;}
if(pp->str.Right(1)=='s'){pp->gread=5;}
ab(pp->pDocTemplate);
}
else { return;}

	
}
void CMainFrame::ab(CDocTemplate *pTmp)
{COooDoc*pDoc=new COooDoc();
COooApp*pp=(COooApp*)AfxGetApp();
	CMDIChildWnd * pNewFrame=(CMDIChildWnd *)pTmp->CreateNewFrame(pDoc,NULL);
	if(pp->gread==1){pDoc->SetTitle("一年级");}
	if(pp->gread==2){pDoc->SetTitle("二年级");}
	if(pp->gread==3){pDoc->SetTitle("三年级");}
	if(pp->gread==4){pDoc->SetTitle("四年级");}
	if(pp->gread==5){pDoc->SetTitle("五年级");}
	if(pNewFrame==NULL)
	{
		return;
	}
	pTmp->InitialUpdateFrame(pNewFrame,pDoc);
}


void CMainFrame::OnMenuitem32774() 
{ShowView(theApp.pDocTemplate1,RUNTIME_CLASS(CVV));
	
}

void CMainFrame::OnMenuitem32775() 
{ShowView(theApp.pDocTemplate2,RUNTIME_CLASS(CVV1));
	
}

void CMainFrame::OnMenuitem32776() 
{ShowView(theApp.pDocTemplate3,RUNTIME_CLASS(CTV));
	
}

void CMainFrame::OnMenuitem32777() 
{

	ShowView(theApp.pDocTemplate4,RUNTIME_CLASS(CTV1));
}

void CMainFrame::OnMenuitem32778() 
{ShowView(theApp.pDocTemplate5,RUNTIME_CLASS(CTV2));
	
}

void CMainFrame::ShowView(CDocTemplate *pTmp, CRuntimeClass *pViewClass)
{	CMDIChildWnd * pMDIActive=MDIGetActive();
	CDocument* pDoc=pMDIActive->GetActiveDocument();
	CView* pView;
POSITION pos=pDoc->GetFirstViewPosition();
	while(pos!=NULL)
	{	pView=pDoc->GetNextView(pos);
		if(pView->IsKindOf(pViewClass))
		{
			pView->GetParentFrame()->ActivateFrame();
			return ;}}
	CMDIChildWnd * pNewFrame=(CMDIChildWnd *)pTmp->CreateNewFrame(pDoc,NULL);
	if(pNewFrame==NULL)
	{
		return;
	}	

	pTmp->InitialUpdateFrame(pNewFrame,pDoc);


}

void CMainFrame::OnUpdateMenuitem32777(CCmdUI* pCmdUI) 
{
if(theApp.gread==1||theApp.gread==2)
pCmdUI->Enable(FALSE);	
}

void CMainFrame::OnUpdateFileNew(CCmdUI* pCmdUI) 
{
if(theApp.f||theApp.a||theApp.b||theApp.c||theApp.d||theApp.e)
pCmdUI->Enable(FALSE);	
}

void CMainFrame::OnUpdateFileOpen(CCmdUI* pCmdUI) 
{
if(theApp.f||theApp.a||theApp.b||theApp.c||theApp.d||theApp.e)
pCmdUI->Enable(FALSE);	
	
}

⌨️ 快捷键说明

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