?? studentscore.cpp
字號:
// StudentScore.cpp : 定義應用程序的類行為。
//
#include "stdafx.h"
#include "StudentScore.h"
#include "MainFrm.h"
#include "ChildFrm.h"
//用戶類模塊
#include "User.h"
//基本信息文檔/視
#include "StudentScoreDoc.h"
#include "StudentScoreView.h"
//考試信息文檔/視
#include "ExamDoc.h"
#include "ExamView.h"
#include "ADODB.h" //數據單元
#include "Loginfrm.h"//登陸窗體
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CStudentScoreApp
BEGIN_MESSAGE_MAP(CStudentScoreApp, CWinApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// 基于文件的標準文檔命令
ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
ON_COMMAND(ID_146, OnBaseView)
ON_COMMAND(ID_149, OnExamView)
END_MESSAGE_MAP()
// CStudentScoreApp 構造
CStudentScoreApp::CStudentScoreApp()
{
// TODO: 在此處添加構造代碼,
// 將所有重要的初始化放置在 InitInstance 中
}
// 唯一的一個 CStudentScoreApp 對象
CStudentScoreApp theApp;
// CStudentScoreApp 初始化
BOOL CStudentScoreApp::InitInstance()
{
// 如果一個運行在 Windows XP 上的應用程序清單指定要
// 使用 ComCtl32.dll 版本 6 或更高版本來啟用可視化方式,
//則需要 InitCommonControls()。否則,將無法創建窗口。
InitCommonControls();
CWinApp::InitInstance();
// 初始化 OLE 庫
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
// 標準初始化
// 如果未使用這些功能并希望減小
// 最終可執行文件的大小,則應移除下列
// 不需要的特定初始化例程
// 更改用于存儲設置的注冊表項
// TODO: 應適當修改該字符串,
// 例如修改為公司或組織名
//SetRegistryKey(_T("應用程序向導生成的本地應用程序"));
//數據連接及登陸窗體
this->m_pDBCon =new CADOConnection();
this->m_pDBCon->ConDB("StudentScoreDB.mdb","score");
this->m_pUser=new CUser();
CLoginfrm Loginfrm;
if (Loginfrm.DoModal()==IDOK)
{
}
else
{
return false;
}
LoadStdProfileSettings(4); // 加載標準 INI 文件選項(包括 MRU)
// 注冊應用程序的文檔模板。文檔模板
// 將用作文檔、框架窗口和視圖之間的連接
//主過程
// 創建主 MDI 框架窗口
CMainFrame* pMainFrame = new CMainFrame;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
return FALSE;
m_pMainWnd = pMainFrame;
// 僅當具有后綴時才調用 DragAcceptFiles
// 在 MDI 應用程序中,這應在設置 m_pMainWnd 之后立即發生
// 啟用拖/放
m_pMainWnd->DragAcceptFiles();
// 啟用“DDE 執行”
EnableShellOpen();
//RegisterShellFileTypes(TRUE);
// 分析標準外殼命令、DDE、打開文件操作的命令行
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing;
// 調度在命令行中指定的命令。如果
// 用 /RegServer、/Register、/Unregserver 或 /Unregister 啟動應用程序,則返回 FALSE。
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// 主窗口已初始化,因此顯示它并對其進行更新
m_nCmdShow=SW_SHOWMAXIMIZED;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
// 用于應用程序“關于”菜單項的 CAboutDlg 對話框
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// 對話框數據
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 實現
protected:
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
// 用于運行對話框的應用程序命令
void CStudentScoreApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
// CStudentScoreApp 消息處理程序
int CStudentScoreApp::ExitInstance()
{
// TODO: 在此添加專用代碼和/或調用基類
if(this->m_pUser!=NULL)
{
delete this->m_pUser;
this->m_pUser=NULL;
}
if (this->m_pDBCon!=NULL)
{
delete this->m_pDBCon;
this->m_pDBCon=NULL;
}
return CWinApp::ExitInstance();
}
BOOL CStudentScoreApp::InitApplication()
{
// TODO: 在此添加專用代碼和/或調用基類
this->m_pUser=NULL;
this->m_pDBCon=NULL;
this->m_pBaseTemplate=NULL;
this->m_pExamTemplate=NULL;
this->m_pExamStudentTemplate=NULL;
this->m_pExamSubjectTemplate=NULL;
return CWinApp::InitApplication();
}
void CStudentScoreApp::OnBaseView()
{
// TODO: 在此添加命令處理程序代碼
if(this->m_pDocManager==NULL||this->m_pBaseTemplate==NULL)//沒有初始化文檔
{
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_StudentScoreTYPE,
RUNTIME_CLASS(CStudentScoreDoc),
RUNTIME_CLASS(CChildFrame), // 自定義 MDI 子框架
RUNTIME_CLASS(CStudentScoreView));
AddDocTemplate(pDocTemplate);
this->m_pBaseTemplate=pDocTemplate;
RegisterShellFileTypes(TRUE);
pDocTemplate->OpenDocumentFile(NULL);
}
else
{
POSITION p=this->m_pBaseTemplate->GetFirstDocPosition();
if(p)//活動文檔存在
{
CDocument* pDoc=this->m_pBaseTemplate->GetNextDoc(p);
p=pDoc->GetFirstViewPosition();
if(p)//視存在
{
CView* pView=pDoc->GetNextView(p);
pView->GetParentFrame()->BringWindowToTop();
}
}
else
{
this->m_pBaseTemplate->OpenDocumentFile(NULL);
}
}
}
void CStudentScoreApp::OnExamView()
{
// TODO: 在此添加命令處理程序代碼
if(this->m_pDocManager==NULL||this->m_pExamTemplate==NULL)//沒有初始化文檔
{
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(IDR_StudentScoreTYPE,
RUNTIME_CLASS(CExamDoc),
RUNTIME_CLASS(CChildFrame), // 自定義 MDI 子框架
RUNTIME_CLASS(CExamView));
AddDocTemplate(pDocTemplate);
this->m_pExamTemplate=pDocTemplate;
pDocTemplate->OpenDocumentFile(NULL);
}
else
{
POSITION p=this->m_pExamTemplate->GetFirstDocPosition();
if(p)//活動文檔存在
{
CDocument* pDoc=this->m_pExamTemplate->GetNextDoc(p);
p=pDoc->GetFirstViewPosition();
if(p)//視存在
{
CView* pView=pDoc->GetNextView(p);
pView->GetParentFrame()->BringWindowToTop();
}
}
else
{
this->m_pExamTemplate->OpenDocumentFile(NULL);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -