📄 libmisdlg.cpp
字号:
// libmisDlg.cpp : implementation file
//
#include "stdafx.h"
#include "libmis.h"
#include "libmisDlg.h"
#include "uskin.h"
#include "logindlg.h"
#include "admingldlg.h"
#include "ChangepswDlg.h"
#include "BookglDlg.h"
#include "SearchbookDlg.h"
#include "ReaderglDlg.h"
#include "BorrowDlg.h"
#include "AboutDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLibmisDlg dialog
CLibmisDlg::CLibmisDlg(CWnd* pParent /*=NULL*/)
: CDialog(CLibmisDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CLibmisDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CLibmisDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLibmisDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLibmisDlg, CDialog)
//{{AFX_MSG_MAP(CLibmisDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(ID_COLORTHEME, OnColortheme)
ON_COMMAND(ID_LOGIN, OnLogin)
ON_COMMAND(ID_ADMINGL, OnAdmingl)
ON_COMMAND(ID_LOGOUT, OnLogout)
ON_COMMAND(ID_CHANGEPSW, OnChangepsw)
ON_COMMAND(ID_BOOKGL, OnBookgl)
ON_COMMAND(ID_SEARCHBOOK, OnSearchbook)
ON_COMMAND(ID_READERGL, OnReadergl)
ON_COMMAND(ID_BORROWGL, OnBorrowgl)
ON_COMMAND(ID_ABOUT, OnAbout)
ON_COMMAND(ID_EXIT, OnExit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLibmisDlg message handlers
BOOL CLibmisDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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
AfxOleInit();
m_bLogin=FALSE;
EnableGl (FALSE);
return TRUE; // return TRUE unless you set the focus to a control
}
// 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 CLibmisDlg::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 CLibmisDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CLibmisDlg::OnColortheme()
{
// TODO: Add your command handler code here
int n=rand();
float h=n%360;
USkinApplyColorTheme(h,1.0f);
}
void CLibmisDlg::OnLogin()
{
// TODO: Add your command handler code here
CLoginDlg dlg;
if (IDOK==dlg.DoModal ()&&dlg.m_bLogin)
{
MessageBox ("登录成功");
CString str;
str.Format (" 欢迎 %s 的到来! ------ 图书管理系统 v1.0",dlg.m_strName);
SetWindowText (str);
m_bLogin=TRUE;
m_strName=dlg.m_strName;
EnableGl (TRUE);
}
}
void CLibmisDlg::EnableGl(BOOL bEnable)
{
static CMenu* pMenu=GetMenu ()->GetSubMenu (1);
if (bEnable)
bEnable=MF_BYCOMMAND|MF_ENABLED;
else
bEnable=MF_BYCOMMAND|MF_DISABLED;
pMenu->EnableMenuItem (ID_ADMINGL,bEnable);
pMenu->EnableMenuItem (ID_READERGL,bEnable);
pMenu->EnableMenuItem (ID_BOOKGL,bEnable);
pMenu->EnableMenuItem (ID_BORROWGL,bEnable);
pMenu->EnableMenuItem (ID_CHANGEPSW,bEnable);
}
void CLibmisDlg::OnLogout()
{
// TODO: Add your command handler code here
SetWindowText (" 未登录 ------ 图书管理系统 v1.0");
m_bLogin=FALSE;
EnableGl (FALSE);
}
void CLibmisDlg::OnAdmingl()
{
// TODO: Add your command handler code here
CAdminglDlg dlg;
dlg.DoModal ();
}
void CLibmisDlg::OnChangepsw()
{
// TODO: Add your command handler code here
CChangepswDlg dlg;
dlg.m_strName=m_strName;
dlg.DoModal ();
}
void CLibmisDlg::OnBookgl()
{
// TODO: Add your command handler code here
CBookglDlg dlg;
dlg.DoModal ();
}
void CLibmisDlg::OnSearchbook()
{
// TODO: Add your command handler code here
CSearchbookDlg dlg;
dlg.DoModal ();
}
void CLibmisDlg::OnReadergl()
{
// TODO: Add your command handler code here
CReaderglDlg dlg;
dlg.DoModal ();
}
void CLibmisDlg::OnBorrowgl()
{
// TODO: Add your command handler code here
CBorrowDlg dlg;
dlg.DoModal ();
}
void CLibmisDlg::OnAbout()
{
// TODO: Add your command handler code here
CAboutDlg dlg;
dlg.DoModal ();
}
void CLibmisDlg::OnExit()
{
// TODO: Add your command handler code here
CDialog::OnOK ();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -