📄 homefinancemanagerview.cpp
字号:
// HomeFinanceManagerView.cpp : implementation of the CHomeFinanceManagerView class
//
#include "stdafx.h"
#include "HomeFinanceManager.h"
#include "HomeFinanceManagerDoc.h"
#include "HomeFinanceManagerView.h"
#include "CMD.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHomeFinanceManagerView
IMPLEMENT_DYNCREATE(CHomeFinanceManagerView, CView)
BEGIN_MESSAGE_MAP(CHomeFinanceManagerView, CView)
//{{AFX_MSG_MAP(CHomeFinanceManagerView)
ON_WM_SIZE()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHomeFinanceManagerView construction/destruction
CHomeFinanceManagerView::CHomeFinanceManagerView()
{
// TODO: add construction code here
m_ActiveDialog = NULL;
m_bHasClick = false;
}
CHomeFinanceManagerView::~CHomeFinanceManagerView()
{
}
BOOL CHomeFinanceManagerView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CHomeFinanceManagerView drawing
void CHomeFinanceManagerView::OnDraw(CDC* pDC)
{
CHomeFinanceManagerDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
BOOL CHomeFinanceManagerView::OnEraseBkgnd( CDC* pDC )
{
if(!m_bHasClick)
DisplayBackBmp();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CHomeFinanceManagerView printing
BOOL CHomeFinanceManagerView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CHomeFinanceManagerView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CHomeFinanceManagerView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CHomeFinanceManagerView diagnostics
#ifdef _DEBUG
void CHomeFinanceManagerView::AssertValid() const
{
CView::AssertValid();
}
void CHomeFinanceManagerView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CHomeFinanceManagerDoc* CHomeFinanceManagerView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHomeFinanceManagerDoc)));
return (CHomeFinanceManagerDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CHomeFinanceManagerView message handlers
void CHomeFinanceManagerView::DisplayBackBmp()
{
CBitmap Bitmap;
Bitmap.LoadBitmap(IDB_MAINBACK);
BITMAP bmpInfo;
Bitmap.GetBitmap(&bmpInfo);
CDC* pDlgDC = this->GetDC();
CDC MemDC;
MemDC.CreateCompatibleDC(pDlgDC);
MemDC.SelectObject(Bitmap);
RECT rcClient;
this->GetClientRect(&rcClient);
int iWidth = rcClient.right - rcClient.left;
int iHeight = rcClient.bottom - rcClient.top;
pDlgDC->BitBlt(0, 0, iWidth, iHeight, &MemDC, 0, 0,SRCCOPY);
}
//----------------------------------------------------------------------------------
void CHomeFinanceManagerView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
ShowWindow();
}
//----------------------------------------------------------------------------------
void CHomeFinanceManagerView::VerifyUser(void)
{
CHomeFinanceManagerDoc* pDoc = GetDocument();
pDoc->VerifyUser(this);
}
//----------------------------------------------------------------------------------
//更新View信息
void CHomeFinanceManagerView::OnUpdate( CView* pSender, LPARAM lHint, CObject* pHint )
{
CCMD* pCmd = (CCMD*)pHint;
if(pCmd == 0)
{
return;
}
if(pCmd->getType() == CMD_LOGIN)
{
ShowLoginDialog();
}
if(pCmd->getType() == CMD_BALANCE)
{
ShowBalanceDialog();
}
if(pCmd->getType() == CMD_FINANCE_IN)
{
ShowFinanceIn();
}
if(pCmd->getType() == CMD_FINANCE_OUT)
{
ShowFinanceOut();
}
}
//----------------------------------------------------------------------------------
void CHomeFinanceManagerView::ShowLoginDialog()
{
if(!m_DialogLogin)
{
m_DialogLogin.Create(IDD_LOGIN, this);
m_DialogLogin.setParentView(this);
}
if(m_ActiveDialog)
{
m_ActiveDialog->ShowWindow(SW_HIDE);
}
m_ActiveDialog = &m_DialogLogin;
ShowWindow();
}
//----------------------------------------------------------------------------------
//显示收支平衡表
void CHomeFinanceManagerView::ShowBalanceDialog()
{
if(!m_DialogBalance)
{
m_DialogBalance.Create(IDD_BALANCE, this);
}
if(m_ActiveDialog)
{
m_ActiveDialog->ShowWindow(SW_HIDE);
}
m_ActiveDialog = &m_DialogBalance;
ShowWindow();
}
//----------------------------------------------------------------------------------
//显示收入窗口
void CHomeFinanceManagerView::ShowFinanceIn()
{
if(!m_DialogFinanceIn)
{
m_DialogFinanceIn.Create(IDD_FINANCEIN, this);
}
if(m_ActiveDialog)
{
m_ActiveDialog->ShowWindow(SW_HIDE);
}
m_ActiveDialog = &m_DialogFinanceIn;
ShowWindow();
}
//----------------------------------------------------------------------------------
void CHomeFinanceManagerView::ShowFinanceOut()
{
if(!m_DialogFinanceOut)
{
m_DialogFinanceOut.Create(IDD_FINANCEOUT, this);
}
if(m_ActiveDialog)
{
m_ActiveDialog->ShowWindow(SW_HIDE);
}
m_ActiveDialog = &m_DialogFinanceOut;
ShowWindow();
}
//----------------------------------------------------------------------------------
void CHomeFinanceManagerView::ShowWindow()
{
if(m_ActiveDialog)
{
RECT rcClient;
this->GetClientRect(&rcClient);
m_ActiveDialog->MoveWindow(&rcClient,true);
m_ActiveDialog->ShowWindow(SW_SHOW);
m_bHasClick = true;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -