📄 maindlg.cpp
字号:
// MainDlg.cpp : implementation file
//
#include "stdafx.h"
#include "BookManager.h"
#include "MainDlg.h"
#include "BookidinDlg.h"
#include "AboutsysDlg.h"
#include "BkLookupDlg.h"
#include "LibClearDlg.h"
#include "AdminsetDlg.h"
#include "InitDataDlg.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)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CMainDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMainDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMainDlg, CDialog)
//{{AFX_MSG_MAP(CMainDlg)
ON_BN_CLICKED(IDC_Main_cancel, OnMaincancel)
ON_COMMAND(IDM_Bookin, OnBookin)
ON_COMMAND(IDM_Aboutsys, OnAboutsys)
ON_COMMAND(IDM_Bookout, OnBookout)
ON_WM_TIMER()
ON_COMMAND(IDM_Libmanage, OnLibmanage)
ON_COMMAND(IDM_adminmanage, Onadminmanage)
ON_UPDATE_COMMAND_UI(IDM_adminmanage, OnUpdateadminmanage)
ON_UPDATE_COMMAND_UI(IDM_Initial, OnUpdateInitial)
ON_COMMAND(IDM_Initial, OnInitial)
ON_WM_INITMENUPOPUP()
ON_COMMAND(IDM_Exit, OnExit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMainDlg message handlers
void CMainDlg::OnMaincancel()
{
// TODO: Add your control notification handler code here
CDialog::OnOK();
}
void CMainDlg::OnBookin()
{
// TODO: Add your command handler code here
CBookidinDlg dlg;
dlg.DoModal();
}
void CMainDlg::OnAboutsys()
{
// TODO: Add your command handler code here
CAboutsysDlg dlg;
dlg.DoModal();
}
void CMainDlg::OnBookout()
{
// TODO: Add your command handler code here
CBkLookupDlg dlg;
dlg.DoModal();
}
BOOL CMainDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CTime t=CTime::GetCurrentTime();
CString s=t.Format("%H:%M:%S");
CRect rect;
this->GetClientRect(&rect);
m_status.Create(WS_CHILD|WS_VISIBLE|CCS_BOTTOM,rect,this,ID_STATUS_BAR);
int indic[3];
indic[0]=rect.Width()/2;
indic[1]=rect.Width()*3/4;
indic[2]=rect.Width();
m_status.SetParts(3,indic);
CString str;
str.LoadString(IDS_CQJT);
m_status.SetText(str,0,0);
CBookManagerApp* app=(CBookManagerApp *)::AfxGetApp();
m_status.SetText("当前管理员:"+app->admin_id,1,0);
m_status.SetText(s,2,0);
this->SetTimer(1,1000,NULL);
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CMainDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CTime t=CTime::GetCurrentTime();
CString s=t.Format("%H:%M:%S");
s="当前时间:"+s;
this->m_status.SetText(s,2,0);
CDialog::OnTimer(nIDEvent);
}
void CMainDlg::OnLibmanage()
{
// TODO: Add your command handler code here
CLibClearDlg dlg;
dlg.DoModal();
}
void CMainDlg::Onadminmanage()
{
// TODO: Add your command handler code here
CAdminsetDlg dlg;
dlg.DoModal();
}
void CMainDlg::OnUpdateadminmanage(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
CBookManagerApp* app=(CBookManagerApp*)::AfxGetApp();
if(!app->IsPower)
{
pCmdUI->Enable(FALSE);
}
}
void CMainDlg::OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
ASSERT(pPopupMenu != NULL);
// Check the enabled state of various menu items.
CCmdUI state;
state.m_pMenu = pPopupMenu;
ASSERT(state.m_pOther == NULL);
ASSERT(state.m_pParentMenu == NULL);
// Determine if menu is popup in top-level menu and set m_pOther to
// it if so (m_pParentMenu == NULL indicates that it is secondary popup).
HMENU hParentMenu;
if (AfxGetThreadState()->m_hTrackingMenu == pPopupMenu->m_hMenu)
state.m_pParentMenu = pPopupMenu; // Parent == child for tracking popup.
else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL)
{
CWnd* pParent = this;
// Child windows don't have menus--need to go to the top!
if (pParent != NULL &&
(hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL)
{
int nIndexMax = ::GetMenuItemCount(hParentMenu);
for (int nIndex = 0; nIndex < nIndexMax; nIndex++)
{
if (::GetSubMenu(hParentMenu, nIndex) == pPopupMenu->m_hMenu)
{
// When popup is found, m_pParentMenu is containing menu.
state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
break;
}
}
}
}
state.m_nIndexMax = pPopupMenu->GetMenuItemCount();
for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
state.m_nIndex++)
{
state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex);
if (state.m_nID == 0)
continue; // Menu separator or invalid cmd - ignore it.
ASSERT(state.m_pOther == NULL);
ASSERT(state.m_pMenu != NULL);
if (state.m_nID == (UINT)-1)
{
// Possibly a popup menu, route to first item of that popup.
state.m_pSubMenu = pPopupMenu->GetSubMenu(state.m_nIndex);
if (state.m_pSubMenu == NULL ||
(state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
state.m_nID == (UINT)-1)
{
continue; // First item of popup can't be routed to.
}
state.DoUpdate(this, TRUE); // Popups are never auto disabled.
}
else
{
// Normal menu item.
// Auto enable/disable if frame window has m_bAutoMenuEnable
// set and command is _not_ a system command.
state.m_pSubMenu = NULL;
state.DoUpdate(this, FALSE);
}
// Adjust for menu deletions and additions.
UINT nCount = pPopupMenu->GetMenuItemCount();
if (nCount < state.m_nIndexMax)
{
state.m_nIndex -= (state.m_nIndexMax - nCount);
while (state.m_nIndex < nCount &&
pPopupMenu->GetMenuItemID(state.m_nIndex) == state.m_nID)
{
state.m_nIndex++;
}
}
state.m_nIndexMax = nCount;
}
}
void CMainDlg::OnUpdateInitial(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
CBookManagerApp* app=(CBookManagerApp*)::AfxGetApp();
if(!app->IsPower)
{
pCmdUI->Enable(FALSE);
}
}
void CMainDlg::OnInitial()
{
// TODO: Add your command handler code here
CInitDataDlg dlg;
dlg.DoModal();
}
void CMainDlg::OnExit()
{
// TODO: Add your command handler code here
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -