ex61View.cpp
资源名称:VC6.0.rar [点击查看]
上传用户:qdhmjx
上传日期:2022-07-11
资源大小:2226k
文件大小:3k
源码类别:
书籍源码
开发平台:
Visual C++
- // ex61View.cpp : implementation of the CEx61View class
- //
- #include "stdafx.h"
- #include "ex61.h"
- #include "ex61Doc.h"
- #include "ex61View.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CEx61View
- IMPLEMENT_DYNCREATE(CEx61View, CView)
- BEGIN_MESSAGE_MAP(CEx61View, CView)
- //{{AFX_MSG_MAP(CEx61View)
- ON_COMMAND(ID_ELLIPSE, OnEllipse)
- ON_COMMAND(ID_RECTANGLE, OnRectangle)
- ON_UPDATE_COMMAND_UI(ID_ELLIPSE, OnUpdateEllipse)
- ON_UPDATE_COMMAND_UI(ID_RECTANGLE, OnUpdateRectangle)
- ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
- ON_COMMAND(ID_EDIT_CUT, OnEditCut)
- ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)
- ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, OnUpdateEditPaste)
- ON_COMMAND(ID_TEXT, OnText)
- //}}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()
- /////////////////////////////////////////////////////////////////////////////
- // CEx61View construction/destruction
- CEx61View::CEx61View()
- {
- flag=-1;
- m_bEditPaste=FALSE;
- }
- CEx61View::~CEx61View()
- {
- }
- BOOL CEx61View::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx61View drawing
- void CEx61View::OnDraw(CDC* pDC)
- {
- CEx61Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data here
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx61View printing
- BOOL CEx61View::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CEx61View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CEx61View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx61View diagnostics
- #ifdef _DEBUG
- void CEx61View::AssertValid() const
- {
- CView::AssertValid();
- }
- void CEx61View::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CEx61Doc* CEx61View::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx61Doc)));
- return (CEx61Doc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CEx61View message handlers
- void CEx61View::OnEllipse()
- {
- Invalidate();//清除窗口内容
- UpdateWindow();
- CDC *pDC=GetDC();
- pDC->Ellipse(100,100,200,200);
- flag=0;
- }
- void CEx61View::OnRectangle()
- {
- Invalidate();//清除窗口内容
- UpdateWindow();
- CDC *pDC=GetDC();
- pDC->Rectangle(100,100,200,200);
- flag=1;
- }
- void CEx61View::OnUpdateEllipse(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(flag==0);
- }
- void CEx61View::OnUpdateRectangle(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(flag==1);
- }
- void CEx61View::OnEditCopy()
- {
- m_bEditPaste=TRUE;
- }
- void CEx61View::OnEditCut()
- {
- m_bEditPaste=TRUE;
- }
- void CEx61View::OnEditPaste()
- {
- AfxMessageBox("There is something to paste!");
- m_bEditPaste=FALSE;
- }
- void CEx61View::OnUpdateEditPaste(CCmdUI* pCmdUI)
- {
- pCmdUI->Enable(m_bEditPaste);
- }
- void CEx61View::OnText()
- {
- CDC *pDC=GetDC();
- pDC->TextOut(100,100,"Hello!");
- }