ex62View.cpp
资源名称:VC6.0.rar [点击查看]
上传用户:qdhmjx
上传日期:2022-07-11
资源大小:2226k
文件大小:4k
源码类别:
书籍源码
开发平台:
Visual C++
- // ex62View.cpp : implementation of the CEx62View class
- //
- #include "stdafx.h"
- #include "ex62.h"
- #include "ex62Doc.h"
- #include "ex62View.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CEx62View
- IMPLEMENT_DYNCREATE(CEx62View, CView)
- BEGIN_MESSAGE_MAP(CEx62View, CView)
- //{{AFX_MSG_MAP(CEx62View)
- ON_WM_CONTEXTMENU()
- ON_COMMAND(ID_ELLIPSE, OnEllipse)
- ON_UPDATE_COMMAND_UI(ID_ELLIPSE, OnUpdateEllipse)
- ON_COMMAND(ID_RECTANGLE, OnRectangle)
- ON_UPDATE_COMMAND_UI(ID_RECTANGLE, OnUpdateRectangle)
- ON_COMMAND(ID_TEXT, OnText)
- ON_COMMAND(ID_PUSHED, OnPushed)
- ON_COMMAND(ID_ENABLE, OnEnable)
- ON_UPDATE_COMMAND_UI(ID_TEXT, OnUpdateText)
- //}}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()
- /////////////////////////////////////////////////////////////////////////////
- // CEx62View construction/destruction
- CEx62View::CEx62View()
- {
- flag=-1;
- m_bPushed=FALSE;
- m_bEnable=TRUE;
- }
- CEx62View::~CEx62View()
- {
- }
- BOOL CEx62View::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx62View drawing
- void CEx62View::OnDraw(CDC* pDC)
- {
- CEx62Doc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- // TODO: add draw code for native data here
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx62View printing
- BOOL CEx62View::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
- void CEx62View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
- void CEx62View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
- /////////////////////////////////////////////////////////////////////////////
- // CEx62View diagnostics
- #ifdef _DEBUG
- void CEx62View::AssertValid() const
- {
- CView::AssertValid();
- }
- void CEx62View::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CEx62Doc* CEx62View::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CEx62Doc)));
- return (CEx62Doc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CEx62View message handlers
- void CEx62View::OnContextMenu(CWnd* pWnd, CPoint point)
- {
- CMenu menu;
- menu.LoadMenu(IDR_POPMENU);
- menu.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON,point.x,point.y,AfxGetMainWnd());
- }
- void CEx62View::OnEllipse()
- {
- Invalidate(); //清除窗口内容
- UpdateWindow(); //加快窗口更新速度
- CDC *pDC=GetDC();
- pDC->Ellipse(100,100,200,200);
- flag=0;
- }
- void CEx62View::OnUpdateEllipse(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck((flag==0)||m_bPushed);
- pCmdUI->Enable(m_bEnable);
- }
- void CEx62View::OnRectangle()
- {
- Invalidate(); //清除窗口内容
- UpdateWindow(); //加快窗口更新速度
- CDC *pDC=GetDC();
- pDC->Rectangle(100,100,200,200);
- flag=1;
- }
- void CEx62View::OnUpdateRectangle(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck((flag==1)||m_bPushed);
- pCmdUI->Enable(m_bEnable);
- }
- void CEx62View::OnText()
- {
- CDC *pDC=GetDC();
- pDC->TextOut(100,100,"Hello!");
- }
- void CEx62View::OnPushed()
- {
- m_bPushed=!m_bPushed;
- }
- void CEx62View::OnEnable()
- {
- m_bEnable=!m_bEnable;
- }
- void CEx62View::OnUpdateText(CCmdUI* pCmdUI)
- {
- pCmdUI->SetCheck(m_bPushed);
- pCmdUI->Enable(m_bEnable);
- }