ex91View.cpp
资源名称:VC6.0.rar [点击查看]
上传用户:qdhmjx
上传日期:2022-07-11
资源大小:2226k
文件大小:3k
源码类别:
书籍源码
开发平台:
Visual C++
- // ex91View.cpp : implementation of the CEx91View class
- //
- #include "stdafx.h"
- #include "ex91.h"
- #include "ex91Doc.h"
- #include "ex91View.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CEx91View
- IMPLEMENT_DYNCREATE(CEx91View, CView)
- BEGIN_MESSAGE_MAP(CEx91View, CView)
- //{{AFX_MSG_MAP(CEx91View)
- 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()
- /////////////////////////////////////////////////////////////////////////////
- // CEx91View construction/destruction
- CEx91View::CEx91View()
- {
- // TODO: add construction code here
- }
- CEx91View::~CEx91View()
- {
- }
- BOOL CEx91View::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx91View drawing
- void CEx91View::OnDraw(CDC* pDC)
- {
- CEx91Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- pDC->Ellipse(x-50,y-50,x+50,y+50);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx91View printing
- BOOL CEx91View::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CEx91View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CEx91View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx91View diagnostics
- #ifdef _DEBUG
- void CEx91View::AssertValid() const
- {
- CView::AssertValid();
- }
- void CEx91View::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CEx91Doc* CEx91View::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx91Doc)));
- return (CEx91Doc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CEx91View message handlers
- void CEx91View::OnLButtonDown(UINT nFlags, CPoint point)
- {
- x=point.x;//先修改视图类数据成员
- y=point.y;
- GetDocument()->x=x;//再把修改结果传到文档类
- GetDocument()->y=y;
- GetDocument()->SetModifiedFlag();
- Invalidate();
- /*
- GetDocument()->x=point.x;//修改文档数据
- GetDocument()->y=point.y;
- GetDocument()->SetModifiedFlag();//文档数据修改后,关闭文档时提示存盘
- Invalidate();//文档数据改变后,要及时通知视图,按修改后的数据重新绘制窗口
- */
- CView::OnLButtonDown(nFlags, point);
- }
- void CEx91View::OnInitialUpdate()
- {
- CView::OnInitialUpdate();
- x=GetDocument()->x;//把文档数据传给视图
- y=GetDocument()->y;
- }