SuperMarketView.cpp
上传用户:tyjx315
上传日期:2015-01-18
资源大小:1685k
文件大小:4k
- // SuperMarketView.cpp : implementation of the CSuperMarketView class
- //
- #include "stdafx.h"
- #include "SuperMarket.h"
- #include "SuperMarketDoc.h"
- #include "SuperMarketView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CSuperMarketView
- IMPLEMENT_DYNCREATE(CSuperMarketView, CView)
- BEGIN_MESSAGE_MAP(CSuperMarketView, CView)
- //{{AFX_MSG_MAP(CSuperMarketView)
- ON_WM_ERASEBKGND()
- ON_WM_PAINT()
- //}}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()
- /////////////////////////////////////////////////////////////////////////////
- // CSuperMarketView construction/destruction
- CSuperMarketView::CSuperMarketView()
- {
- // TODO: add construction code here
- }
- CSuperMarketView::~CSuperMarketView()
- {
- }
- BOOL CSuperMarketView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
-
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CSuperMarketView drawing
- void CSuperMarketView::OnDraw(CDC* pDC)
- {
- CSuperMarketDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data here
- /* CString str;
- str.LoadString(IDS_COPYRIGHT);
- pDC->TextOut(100,100,str);
- */
- }
- /////////////////////////////////////////////////////////////////////////////
- // CSuperMarketView printing
- BOOL CSuperMarketView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CSuperMarketView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CSuperMarketView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CSuperMarketView diagnostics
- #ifdef _DEBUG
- void CSuperMarketView::AssertValid() const
- {
- CView::AssertValid();
- }
- void CSuperMarketView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CSuperMarketDoc* CSuperMarketView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSuperMarketDoc)));
- return (CSuperMarketDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CSuperMarketView message handlers
- BOOL CSuperMarketView::OnEraseBkgnd(CDC* pDC)
- {
- // TODO: Add your message handler code here and/or call default
- /* CRect m_rt;
- GetClientRect(&m_rt);
- CBrush brush;
- brush.CreateSolidBrush(RGB(10,120,50));
- pDC->FillRect(&m_rt,&brush);
- */
- // return true;
- return CView::OnEraseBkgnd(pDC);
- }
- void CSuperMarketView::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
-
-
- CRect rect;
- GetClientRect(&rect);//得到窗体的大小
- CDC dcMem;
- dcMem.CreateCompatibleDC(&dc);
- CBitmap bmpBackground;
- bmpBackground.LoadBitmap(IDB_BITMAP1);//加载背景图片
- BITMAP bitMap;
-
- bmpBackground.GetBitmap(&bitMap);
- CBitmap *pbmpOld=dcMem.SelectObject(&bmpBackground);
- dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,bitMap.bmWidth,bitMap.bmHeight,SRCCOPY);//画窗体
-
-
-
- CFont font;
- font.CreateFont(20,20,0,0, FW_NORMAL, // nWeight
- FALSE, // bItalic
- FALSE, // bUnderline
- 0, // cStrikeOut
- ANSI_CHARSET, // nCharSet
- OUT_DEFAULT_PRECIS, // nOutPrecision
- CLIP_DEFAULT_PRECIS, // nClipPrecision
- DEFAULT_QUALITY, // nQuality
- DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
- "Arial");
- CString str;
-
- str.LoadString(IDS_COPYRIGHT);
- dc.SelectObject(&font);
- dc.SetBkColor(RGB(10,10,200)); //背景颜色
-
-
- dc.SetTextColor((0,200,0)); //文本颜色
-
- // dc.TextOut(80,30,str);
- // dc.TextOut(180,50,"----------丁虎平,王国平,申玉");
- // TODO: Add your message handler code here
- // Do not call CView::OnPaint() for painting messages
-
-
- }