📄 stumanagedlg.cpp
字号:
// StuManageDlg.cpp : implementation file
//
#include "stdafx.h"
#include "StuManage.h"
#include "StuManageDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
extern CStuManageApp theApp;
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStuManageDlg dialog
CStuManageDlg::CStuManageDlg(CWnd* pParent /*=NULL*/)
: CDialog(CStuManageDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CStuManageDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CStuManageDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStuManageDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStuManageDlg, CDialog)
//{{AFX_MSG_MAP(CStuManageDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(ID_STUDENT_MENU, OnStudentMenu)
ON_COMMAND(ID_DEPARTMENT_MENU, OnDepartmentMenu)
ON_COMMAND(ID_COURSE_MENU, OnCourseMenu)
ON_COMMAND(ID_SCORE_MENU, OnScoreMenu)
ON_COMMAND(ID_STATUS_MENU, OnStatusMenu)
ON_COMMAND(ID_ENC_PUN_MENU, OnEncPunMenu)
ON_COMMAND(ID_LOGIN_MENU, OnLoginMenu)
ON_COMMAND(ID_LOGOUT_MENU, OnLogoutMenu)
ON_COMMAND(ID_EXIT_MENU, OnExitMenu)
ON_COMMAND(ID_PHOTO_MENU, OnPhotoMenu)
ON_COMMAND(ID_EXPERIENCE_MENU, OnExperienceMenu)
ON_COMMAND(ID_USER_MENU, OnUserMenu)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStuManageDlg message handlers
BOOL CStuManageDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
for(int i=0;i<10;i++)
status[i] = FALSE;
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP_BK);
m_brBk.CreatePatternBrush(&bmp);
bmp.DeleteObject();
//未登录
theApp.Loginstatus=false;
return TRUE; // return TRUE unless you set the focus to a control
}
void CStuManageDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CStuManageDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CStuManageDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CStuManageDlg::OnStudentMenu()
{
// TODO: Add your command handler code here
SetDlgStatus();
//判断用户是否登录系统
if (theApp.Loginstatus )
{
m_StudentDlg = new CStudentDlg;
m_StudentDlg->Create(IDD_STUDENT_DLG, this);
status[1] = TRUE;
}
else
{
MessageBox("请先登录系统","提示");
}
}
void CStuManageDlg::OnDepartmentMenu()
{
// TODO: Add your command handler code here
SetDlgStatus();
//判断用户是否登录系统
if (theApp.Loginstatus )
{
m_DepartmentDlg = new CDepartmentDlg;
m_DepartmentDlg->Create(IDD_DEPARTMENT_DLG, this);
status[4] = TRUE;
}
else
{
MessageBox("请先登录系统","提示");
}
}
void CStuManageDlg::OnCourseMenu()
{
// TODO: Add your command handler code here
SetDlgStatus();
//判断用户是否登录系统
if (theApp.Loginstatus )
{
m_CourseDlg = new CCourseDlg;
m_CourseDlg->Create(IDD_COURSE_DLG, this);
status[5] = TRUE;
}
else
{
MessageBox("请先登录系统","提示");
}
}
void CStuManageDlg::OnScoreMenu()
{
// TODO: Add your command handler code here
SetDlgStatus();
//判断用户是否登录系统
if (theApp.Loginstatus )
{
m_ScoreDlg = new CScoreDlg;
m_ScoreDlg->Create(IDD_SCORE_DLG, this);
status[6] = TRUE;
}
else
{
MessageBox("请先登录系统","提示");
}
}
void CStuManageDlg::OnStatusMenu()
{
// TODO: Add your command handler code here
SetDlgStatus();
//判断用户是否登录系统
if (theApp.Loginstatus )
{
m_StatusDlg = new CStatusDlg;
m_StatusDlg->Create(IDD_STATUS_DLG, this);
status[7] = TRUE;
}
else
{
MessageBox("请先登录系统","提示");
}
}
void CStuManageDlg::OnEncPunMenu()
{
// TODO: Add your command handler code here
SetDlgStatus();
//判断用户是否登录系统
if (theApp.Loginstatus )
{
m_EncPunDlg = new CEncPunDlg;
m_EncPunDlg->Create(IDD_ENC_PUN_DLG, this);
status[8] = TRUE;
}
else
{
MessageBox("请先登录系统","提示");
}
}
void CStuManageDlg::OnLoginMenu()
{
// TODO: Add your command handler code here
SetDlgStatus();
m_LoginDlg = new CLoginDlg;
m_LoginDlg->Create(IDD_LOGIN_DLG, this);
status[0] = TRUE;
}
void CStuManageDlg::OnLogoutMenu()
{
// TODO: Add your command handler code here
theApp.m_Level = -1;
theApp.Loginstatus =false;
MessageBox("本次登录已注销","提示");
}
void CStuManageDlg::OnExitMenu()
{
// TODO: Add your command handler code here
if(MessageBox("真的要退出系统吗?","退出询问",MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
CDialog::OnOK();
}
void CStuManageDlg::OnPhotoMenu()
{
// TODO: Add your command handler code here
SetDlgStatus();
//判断用户是否登录系统
if (theApp.Loginstatus )
{
m_PhotoDlg = new CPhotoDlg;
m_PhotoDlg->Create(IDD_PHOTO_DLG, this);
status[2] = TRUE;
}
else
{
MessageBox("请先登录系统","提示");
}
}
void CStuManageDlg::OnExperienceMenu()
{
// TODO: Add your command handler code here
SetDlgStatus();
//判断用户是否登录系统
if (theApp.Loginstatus )
{
m_ExperienceDlg = new CExperienceDlg;
m_ExperienceDlg->Create(IDD_EXPERIENCE_DLG, this);
status[3] = TRUE;
}
else
{
MessageBox("请先登录系统","提示");
}
}
void CStuManageDlg::SetDlgStatus()
{
if(status[0])
{
m_LoginDlg->DestroyWindow();
status[0] = FALSE;
}
if(status[1])
{
m_StudentDlg->DestroyWindow();
status[1] = FALSE;
}
if(status[2])
{
m_PhotoDlg->DestroyWindow();
status[2] = FALSE;
}
if(status[3])
{
m_ExperienceDlg->DestroyWindow();
status[3] = FALSE;
}
if(status[4])
{
m_DepartmentDlg->DestroyWindow();
status[4] = FALSE;
}
if(status[5])
{
m_CourseDlg->DestroyWindow();
status[5] = FALSE;
}
if(status[6])
{
m_ScoreDlg->DestroyWindow();
status[6] = FALSE;
}
if(status[7])
{
m_StatusDlg->DestroyWindow();
status[7] = FALSE;
}
if(status[8])
{
m_EncPunDlg->DestroyWindow();
status[8] = FALSE;
}
if(status[9])
{
m_UserDlg->DestroyWindow();
status[9] = FALSE;
}
}
void CStuManageDlg::OnUserMenu()
{
// TODO: Add your command handler code here
SetDlgStatus();
//判断用户是否登录系统
if (theApp.Loginstatus )
{
m_UserDlg = new CUserDlg;
m_UserDlg->Create(IDD_USER_DLG, this);
status[9] = TRUE;
}
else
{
MessageBox("请先登录系统","提示");
}
}
HBRUSH CStuManageDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if (pWnd == this)
{
return m_brBk;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -