📄 maindlg.cpp
字号:
// MainDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Library.h"
#include "MainDlg.h"
#include "LibraryDlg.h"
#include "PasswdDlg.h"
#include "BorrowDlg.h"
#include "CheckBorrowDlg.h"
#include "NewBooksDlg.h"
#include "CheckBooksDlg.h"
#include "BookLostDlg.h"
#include "AboutDlg.h"
#include "NewProofDlg.h"
#include "CheckProofDlg.h"
#include "ProofLostDlg.h"
#include "BeginDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainDlg dialog
CMainDlg::CMainDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMainDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMainDlg)
m_strUser = _T("");
m_strTime = _T("");
//}}AFX_DATA_INIT
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMainDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMainDlg)
DDX_Text(pDX, IDC_STATIC_PERSON, m_strUser);
DDX_Text(pDX, IDC_STATIC_TIMER, m_strTime);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMainDlg, CDialog)
//{{AFX_MSG_MAP(CMainDlg)
ON_COMMAND(ID_MENU_EXIT, OnMenuExit)
ON_COMMAND(ID_MENU_LOGOUT, OnMenuLogout)
ON_COMMAND(ID_MENU_PASSWORD, OnMenuPassword)
ON_WM_CLOSE()
ON_COMMAND(ID_MENU_BORROW, OnMenuBorrow)
ON_WM_TIMER()
ON_COMMAND(ID_MENU_CHECK_BORROW, OnMenuCheckBorrow)
ON_COMMAND(ID_MENU_NEW_BOOKS, OnMenuNewBooks)
ON_COMMAND(ID_MENU_CHECK_BOOKS, OnMenuCheckBooks)
ON_COMMAND(ID_MENU_BOOK_LOST, OnMenuBookLost)
ON_COMMAND(ID_MENU_HOWTO, OnMenuHowto)
ON_COMMAND(ID_MENU_ABOUT, OnMenuAbout)
ON_COMMAND(ID_MENU_MAKE_PROOF, OnMenuMakeProof)
ON_COMMAND(ID_MENU_CHECK_PROOF, OnMenuCheckProof)
ON_COMMAND(ID_MENU_PROOF_LOST, OnMenuProofLost)
ON_BN_CLICKED(IDC_BUTTON_BEGIN, OnButtonBegin)
ON_WM_QUERYDRAGICON()
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainDlg message handlers
void CMainDlg::OnMenuExit()
{
int iResult=MessageBox("Will you really quit?","图书管理系统",MB_YESNO|MB_ICONQUESTION);
if(iResult==IDYES)
OnOK();
}
void CMainDlg::OnMenuLogout()
{
int iResult=MessageBox("Really logout?","图书管理系统",MB_OKCANCEL|MB_ICONQUESTION);
if(iResult==IDOK)
{
CLibraryDlg LoginDlg;
OnOK();
LoginDlg.DoModal();
}
}
void CMainDlg::OnMenuPassword()
{
CPasswdDlg m_PassDlg;
m_PassDlg.m_user=m_user;
m_PassDlg.DoModal();
}
void CMainDlg::OnClose()
{
OnMenuExit();
}
void CMainDlg::OnMenuBorrow()
{
CBorrowDlg dlg;
dlg.DoModal();
}
BOOL CMainDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetTimer(MAINTIMER,1000,NULL);
m_strUser="现在登录者为:"+m_user;
UpdateData(FALSE);
//添加工具条
CRect rect;
GetClientRect(rect);
if(!m_wndToolBar.Create(this))
{
TRACE0("Failed to create tool bar\n");
return -1;
}
m_wndToolBar.LoadToolBar(IDR_TOOLBAR_MAIN);
m_wndToolBar.MoveWindow(0,0,rect.right,32);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMainDlg::OnTimer(UINT nIDEvent)
{
CTime curTime=CTime::GetCurrentTime();
m_strTime="当前系统时间是 "+curTime.Format("%y-%m-%d %H:%M:%S");
UpdateData(FALSE);
CDialog::OnTimer(nIDEvent);
}
void CMainDlg::OnMenuCheckBorrow()
{
CCheckBorrowDlg dlg;
dlg.DoModal();
}
void CMainDlg::OnMenuNewBooks()
{
CNewBooksDlg NewDlg;
NewDlg.DoModal();
}
void CMainDlg::OnMenuCheckBooks()
{
CCheckBooksDlg dlg;
dlg.DoModal();
}
void CMainDlg::OnMenuBookLost()
{
CBookLostDlg m_dlg;
m_dlg.DoModal();
}
void CMainDlg::OnMenuHowto()
{
WinExec("hh.exe help\\help.chm",SW_SHOW);
}
void CMainDlg::OnMenuAbout()
{
CAboutDlg m_dlg;
m_dlg.DoModal();
}
void CMainDlg::OnMenuMakeProof()
{
CNewProofDlg m_dlg;
m_dlg.DoModal();
}
void CMainDlg::OnMenuCheckProof()
{
CCheckProofDlg m_dlg;
m_dlg.DoModal();
}
void CMainDlg::OnMenuProofLost()
{
CProofLostDlg m_dlg;
m_dlg.DoModal();
}
void CMainDlg::OnButtonBegin()
{
CBeginDlg m_dlg;
m_dlg.m_struser=m_user;
OnOK();
m_dlg.DoModal();
}
HCURSOR CMainDlg::OnQueryDragIcon()
{
// TODO: Add your message handler code here and/or call default
return (HCURSOR) m_hIcon;
}
void CMainDlg::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();
}
// Do not call CDialog::OnPaint() for painting messages
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -