SuperMarketView.cpp
上传用户:tyjx315
上传日期:2015-01-18
资源大小:1685k
文件大小:4k
源码类别:

百货/超市行业

开发平台:

Visual C++

  1. // SuperMarketView.cpp : implementation of the CSuperMarketView class
  2. //
  3. #include "stdafx.h"
  4. #include "SuperMarket.h"
  5. #include "SuperMarketDoc.h"
  6. #include "SuperMarketView.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CSuperMarketView
  14. IMPLEMENT_DYNCREATE(CSuperMarketView, CView)
  15. BEGIN_MESSAGE_MAP(CSuperMarketView, CView)
  16. //{{AFX_MSG_MAP(CSuperMarketView)
  17. ON_WM_ERASEBKGND()
  18. ON_WM_PAINT()
  19. //}}AFX_MSG_MAP
  20. // Standard printing commands
  21. ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  22. ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  23. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  24. END_MESSAGE_MAP()
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CSuperMarketView construction/destruction
  27. CSuperMarketView::CSuperMarketView()
  28. {
  29. // TODO: add construction code here
  30. }
  31. CSuperMarketView::~CSuperMarketView()
  32. {
  33. }
  34. BOOL CSuperMarketView::PreCreateWindow(CREATESTRUCT& cs)
  35. {
  36. // TODO: Modify the Window class or styles here by modifying
  37. //  the CREATESTRUCT cs
  38.     
  39. return CView::PreCreateWindow(cs);
  40. }
  41. /////////////////////////////////////////////////////////////////////////////
  42. // CSuperMarketView drawing
  43. void CSuperMarketView::OnDraw(CDC* pDC)
  44. {
  45. CSuperMarketDoc* pDoc = GetDocument();
  46. ASSERT_VALID(pDoc);
  47. // TODO: add draw code for native data here
  48. /* CString str;
  49. str.LoadString(IDS_COPYRIGHT);
  50. pDC->TextOut(100,100,str);
  51. */
  52. }
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CSuperMarketView printing
  55. BOOL CSuperMarketView::OnPreparePrinting(CPrintInfo* pInfo)
  56. {
  57. // default preparation
  58. return DoPreparePrinting(pInfo);
  59. }
  60. void CSuperMarketView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  61. {
  62. // TODO: add extra initialization before printing
  63. }
  64. void CSuperMarketView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  65. {
  66. // TODO: add cleanup after printing
  67. }
  68. /////////////////////////////////////////////////////////////////////////////
  69. // CSuperMarketView diagnostics
  70. #ifdef _DEBUG
  71. void CSuperMarketView::AssertValid() const
  72. {
  73. CView::AssertValid();
  74. }
  75. void CSuperMarketView::Dump(CDumpContext& dc) const
  76. {
  77. CView::Dump(dc);
  78. }
  79. CSuperMarketDoc* CSuperMarketView::GetDocument() // non-debug version is inline
  80. {
  81. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSuperMarketDoc)));
  82. return (CSuperMarketDoc*)m_pDocument;
  83. }
  84. #endif //_DEBUG
  85. /////////////////////////////////////////////////////////////////////////////
  86. // CSuperMarketView message handlers
  87. BOOL CSuperMarketView::OnEraseBkgnd(CDC* pDC) 
  88. {
  89. // TODO: Add your message handler code here and/or call default
  90. /* CRect   m_rt;   
  91.     GetClientRect(&m_rt);   
  92.     CBrush   brush;   
  93.     brush.CreateSolidBrush(RGB(10,120,50));   
  94.     pDC->FillRect(&m_rt,&brush);   
  95. */
  96. //  return true;     
  97. return CView::OnEraseBkgnd(pDC);
  98. }
  99. void CSuperMarketView::OnPaint() 
  100. {
  101. CPaintDC dc(this); // device context for painting
  102.     
  103. CRect   rect;   
  104.     GetClientRect(&rect);//得到窗体的大小   
  105.     CDC   dcMem;     
  106.     dcMem.CreateCompatibleDC(&dc);     
  107.     CBitmap   bmpBackground;   
  108.     bmpBackground.LoadBitmap(IDB_BITMAP1);//加载背景图片   
  109.     BITMAP   bitMap;   
  110.     
  111. bmpBackground.GetBitmap(&bitMap);   
  112.     CBitmap   *pbmpOld=dcMem.SelectObject(&bmpBackground);   
  113.     dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,bitMap.bmWidth,bitMap.bmHeight,SRCCOPY);//画窗体
  114. CFont font;
  115. font.CreateFont(20,20,0,0,        FW_NORMAL,                 // nWeight
  116. FALSE,                     // bItalic
  117. FALSE,                     // bUnderline
  118. 0,                         // cStrikeOut
  119. ANSI_CHARSET,              // nCharSet
  120. OUT_DEFAULT_PRECIS,        // nOutPrecision
  121. CLIP_DEFAULT_PRECIS,       // nClipPrecision
  122. DEFAULT_QUALITY,           // nQuality
  123. DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
  124. "Arial");
  125. CString str;
  126. str.LoadString(IDS_COPYRIGHT);
  127. dc.SelectObject(&font);
  128. dc.SetBkColor(RGB(10,10,200)); //背景颜色
  129. dc.SetTextColor((0,200,0));  //文本颜色
  130. // dc.TextOut(80,30,str);
  131. // dc.TextOut(180,50,"----------丁虎平,王国平,申玉");
  132. // TODO: Add your message handler code here
  133. // Do not call CView::OnPaint() for painting messages
  134.   
  135.  
  136. }