GraphicsView.cpp
资源名称:VC6.0.rar [点击查看]
上传用户:qdhmjx
上传日期:2022-07-11
资源大小:2226k
文件大小:3k
源码类别:
书籍源码
开发平台:
Visual C++
- // GraphicsView.cpp : implementation of the CGraphicsView class
- //
- #include "stdafx.h"
- #include "Graphics.h"
- #include "GraphicsDoc.h"
- #include "GraphicsView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CGraphicsView
- IMPLEMENT_DYNCREATE(CGraphicsView, CView)
- BEGIN_MESSAGE_MAP(CGraphicsView, CView)
- //{{AFX_MSG_MAP(CGraphicsView)
- ON_WM_LBUTTONDOWN()
- //}}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()
- /////////////////////////////////////////////////////////////////////////////
- // CGraphicsView construction/destruction
- CGraphicsView::CGraphicsView()
- {
- // TODO: add construction code here
- m_bLbuttonDown=FALSE;
- }
- CGraphicsView::~CGraphicsView()
- {
- }
- BOOL CGraphicsView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CGraphicsView drawing
- void CGraphicsView::OnDraw(CDC* pDC)
- {
- CGraphicsDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data here
- if(m_bLbuttonDown)
- {
- CDC *pDC=GetDC();
- CRect rect;
- GetClientRect(&rect);//获得客户区的位置放在rect中
- pDC->Ellipse(&rect); //画一个充满整个客户区的椭圆
- pDC->Rectangle(100,100,200,200); //画一矩形
- }
- }
- /////////////////////////////////////////////////////////////////////////////
- // CGraphicsView printing
- BOOL CGraphicsView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CGraphicsView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CGraphicsView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CGraphicsView diagnostics
- #ifdef _DEBUG
- void CGraphicsView::AssertValid() const
- {
- CView::AssertValid();
- }
- void CGraphicsView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CGraphicsDoc* CGraphicsView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CGraphicsDoc)));
- return (CGraphicsDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CGraphicsView message handlers
- void CGraphicsView::OnLButtonDown(UINT nFlags, CPoint point)
- {
- m_bLbuttonDown=true;
- Invalidate();
- CView::OnLButtonDown(nFlags, point);
- }