HomeFinanceManagerView.cpp
上传用户:xiaoke98
上传日期:2014-06-29
资源大小:5718k
文件大小:6k
源码类别:

家庭/个人应用

开发平台:

Visual C++

  1. // HomeFinanceManagerView.cpp : implementation of the CHomeFinanceManagerView class
  2. //
  3. #include "stdafx.h"
  4. #include "HomeFinanceManager.h"
  5. #include "HomeFinanceManagerDoc.h"
  6. #include "HomeFinanceManagerView.h"
  7. #include "CMD.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CHomeFinanceManagerView
  15. IMPLEMENT_DYNCREATE(CHomeFinanceManagerView, CView)
  16. BEGIN_MESSAGE_MAP(CHomeFinanceManagerView, CView)
  17. //{{AFX_MSG_MAP(CHomeFinanceManagerView)
  18. ON_WM_SIZE()
  19. ON_WM_ERASEBKGND() 
  20. //}}AFX_MSG_MAP
  21. // Standard printing commands
  22. ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  23. ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  24. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  25. END_MESSAGE_MAP()
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CHomeFinanceManagerView construction/destruction
  28. CHomeFinanceManagerView::CHomeFinanceManagerView()
  29. {
  30. // TODO: add construction code here
  31. m_ActiveDialog = NULL;
  32. m_bHasClick = false;
  33. }
  34. CHomeFinanceManagerView::~CHomeFinanceManagerView()
  35. {
  36. }
  37. BOOL CHomeFinanceManagerView::PreCreateWindow(CREATESTRUCT& cs)
  38. {
  39. // TODO: Modify the Window class or styles here by modifying
  40. //  the CREATESTRUCT cs
  41. return CView::PreCreateWindow(cs);
  42. }
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CHomeFinanceManagerView drawing
  45. void CHomeFinanceManagerView::OnDraw(CDC* pDC)
  46. {
  47. CHomeFinanceManagerDoc* pDoc = GetDocument();
  48. ASSERT_VALID(pDoc);
  49. // TODO: add draw code for native data here
  50. }
  51. BOOL CHomeFinanceManagerView::OnEraseBkgnd( CDC* pDC )
  52. {
  53. if(!m_bHasClick)
  54. DisplayBackBmp();
  55. return TRUE;
  56. }
  57. /////////////////////////////////////////////////////////////////////////////
  58. // CHomeFinanceManagerView printing
  59. BOOL CHomeFinanceManagerView::OnPreparePrinting(CPrintInfo* pInfo)
  60. {
  61. // default preparation
  62. return DoPreparePrinting(pInfo);
  63. }
  64. void CHomeFinanceManagerView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  65. {
  66. // TODO: add extra initialization before printing
  67. }
  68. void CHomeFinanceManagerView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  69. {
  70. // TODO: add cleanup after printing
  71. }
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CHomeFinanceManagerView diagnostics
  74. #ifdef _DEBUG
  75. void CHomeFinanceManagerView::AssertValid() const
  76. {
  77. CView::AssertValid();
  78. }
  79. void CHomeFinanceManagerView::Dump(CDumpContext& dc) const
  80. {
  81. CView::Dump(dc);
  82. }
  83. CHomeFinanceManagerDoc* CHomeFinanceManagerView::GetDocument() // non-debug version is inline
  84. {
  85. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CHomeFinanceManagerDoc)));
  86. return (CHomeFinanceManagerDoc*)m_pDocument;
  87. }
  88. #endif //_DEBUG
  89. /////////////////////////////////////////////////////////////////////////////
  90. // CHomeFinanceManagerView message handlers
  91. void  CHomeFinanceManagerView::DisplayBackBmp()
  92. {
  93. CBitmap Bitmap;
  94. Bitmap.LoadBitmap(IDB_MAINBACK);
  95. BITMAP bmpInfo;
  96. Bitmap.GetBitmap(&bmpInfo);
  97. CDC* pDlgDC = this->GetDC();
  98. CDC MemDC;
  99. MemDC.CreateCompatibleDC(pDlgDC);
  100. MemDC.SelectObject(Bitmap);
  101. RECT rcClient;
  102. this->GetClientRect(&rcClient);
  103. int iWidth = rcClient.right - rcClient.left;
  104. int iHeight = rcClient.bottom - rcClient.top;
  105. pDlgDC->BitBlt(0, 0, iWidth, iHeight, &MemDC, 0, 0,SRCCOPY);
  106. }
  107. //----------------------------------------------------------------------------------
  108. void CHomeFinanceManagerView::OnSize(UINT nType, int cx, int cy) 
  109. {
  110. CView::OnSize(nType, cx, cy);
  111. // TODO: Add your message handler code here
  112. ShowWindow();
  113. }
  114. //----------------------------------------------------------------------------------
  115. void CHomeFinanceManagerView::VerifyUser(void)
  116. {
  117. CHomeFinanceManagerDoc* pDoc =  GetDocument();
  118. pDoc->VerifyUser(this);
  119. }
  120. //----------------------------------------------------------------------------------
  121. //更新View信息
  122. void CHomeFinanceManagerView::OnUpdate( CView* pSender, LPARAM lHint, CObject* pHint )
  123. {
  124. CCMD* pCmd = (CCMD*)pHint;
  125. if(pCmd == 0)
  126. {
  127. return;
  128. }
  129. if(pCmd->getType() == CMD_LOGIN)
  130. {
  131. ShowLoginDialog();
  132. }
  133. if(pCmd->getType() == CMD_BALANCE)
  134. {
  135. ShowBalanceDialog();
  136. }
  137. if(pCmd->getType() == CMD_FINANCE_IN)
  138. {
  139. ShowFinanceIn();
  140. }
  141. if(pCmd->getType() == CMD_FINANCE_OUT)
  142. {
  143. ShowFinanceOut();
  144. }
  145. }
  146. //----------------------------------------------------------------------------------
  147. void  CHomeFinanceManagerView::ShowLoginDialog()
  148. {
  149. if(!m_DialogLogin)
  150. {
  151. m_DialogLogin.Create(IDD_LOGIN, this);
  152. m_DialogLogin.setParentView(this);
  153. }
  154. if(m_ActiveDialog)
  155. {
  156. m_ActiveDialog->ShowWindow(SW_HIDE);
  157. }
  158. m_ActiveDialog = &m_DialogLogin;
  159. ShowWindow();
  160. }
  161. //----------------------------------------------------------------------------------
  162. //显示收支平衡表
  163. void    CHomeFinanceManagerView::ShowBalanceDialog()
  164. {
  165. if(!m_DialogBalance)
  166. {
  167. m_DialogBalance.Create(IDD_BALANCE, this);
  168. }
  169. if(m_ActiveDialog)
  170. {
  171. m_ActiveDialog->ShowWindow(SW_HIDE);
  172. }
  173. m_ActiveDialog = &m_DialogBalance;
  174. ShowWindow();
  175. }
  176. //----------------------------------------------------------------------------------
  177. //显示收入窗口
  178. void    CHomeFinanceManagerView::ShowFinanceIn()
  179. {
  180. if(!m_DialogFinanceIn)
  181. {
  182. m_DialogFinanceIn.Create(IDD_FINANCEIN, this);
  183. }
  184. if(m_ActiveDialog)
  185. {
  186. m_ActiveDialog->ShowWindow(SW_HIDE);
  187. }
  188. m_ActiveDialog = &m_DialogFinanceIn;
  189. ShowWindow();
  190. }
  191. //----------------------------------------------------------------------------------
  192. void    CHomeFinanceManagerView::ShowFinanceOut()
  193. {
  194. if(!m_DialogFinanceOut)
  195. {
  196. m_DialogFinanceOut.Create(IDD_FINANCEOUT, this);
  197. }
  198. if(m_ActiveDialog)
  199. {
  200. m_ActiveDialog->ShowWindow(SW_HIDE);
  201. }
  202. m_ActiveDialog = &m_DialogFinanceOut;
  203. ShowWindow();
  204. }
  205. //----------------------------------------------------------------------------------
  206. void CHomeFinanceManagerView::ShowWindow()
  207. {
  208. if(m_ActiveDialog)
  209. {
  210. RECT rcClient;
  211. this->GetClientRect(&rcClient);
  212. m_ActiveDialog->MoveWindow(&rcClient,true);
  213. m_ActiveDialog->ShowWindow(SW_SHOW);
  214. m_bHasClick = true;
  215. }
  216. }