📄 lq01view.cpp
字号:
// lq01View.cpp : implementation of the CLq01View class
//
#include "stdafx.h"
#include "lq01.h"
#include "line.h"
#include "shape.h"
#include "myrect.h"
#include "lq01Doc.h"
#include "lq01View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLq01View
IMPLEMENT_DYNCREATE(CLq01View, CView)
BEGIN_MESSAGE_MAP(CLq01View, CView)
//{{AFX_MSG_MAP(CLq01View)
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_WM_MOUSEMOVE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLq01View construction/destruction
CLq01View::CLq01View()
{
//m_nShape=0;
// TODO: add construction code here
}
CLq01View::~CLq01View()
{
}
BOOL CLq01View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CLq01View drawing
void CLq01View::OnDraw(CDC* pDC)
{
CLq01Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
int iPos;
for (iPos=0;iPos<GetDocument()->GetShapeCount ();iPos++)
{
CShape * pShape=GetDocument()->GetShape(iPos);
pShape->Draw (pDC,pShape->GetPs(),pShape->GetPe(),pShape->GetColor());
}
}
/////////////////////////////////////////////////////////////////////////////
// CLq01View diagnostics
#ifdef _DEBUG
void CLq01View::AssertValid() const
{
CView::AssertValid();
}
void CLq01View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CLq01Doc* CLq01View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CLq01Doc)));
return (CLq01Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CLq01View message handlers
void CLq01View::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
beDraw=TRUE;
m_ptS=m_ptE=m_ptPre=point;
m_MyShape=GetDocument()->CreatShape (m_ptPre,point,m_nColor);
SetCapture();
CView::OnLButtonDown(nFlags, point);
}
void CLq01View::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if (GetCapture() != this)
return;
CDC *pDC=GetDC();
m_MyShape->Draw (pDC,m_ptS,m_ptPre,m_nColor);
m_ptE=point;
beDraw=FALSE;
ReleaseCapture();
if(m_ptS!=m_ptE)
{
m_MyShape=GetDocument()->AddShape (m_ptS,m_ptE,m_nColor);
m_MyShape->Draw (pDC,m_ptS,m_ptE,m_nColor);
}
else
;
CView::OnLButtonUp(nFlags, point);
}
void CLq01View::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(beDraw==TRUE)
{
if((nFlags &MK_LBUTTON)==MK_LBUTTON)
{
if (GetCapture()==this)
{
CDC *pDC=GetDC();
pDC->SelectStockObject (NULL_BRUSH);
pDC->SetROP2 (R2_NOTXORPEN);
m_ptE=point;
m_nShape=GetDocument()->GetShape();
m_nColor=GetDocument()->GetColor ();
m_MyShape->Draw (pDC,m_ptS,m_ptPre,m_nColor);
m_MyShape->Draw (pDC,m_ptS,m_ptE,m_nColor);
m_ptPre=m_ptE;
}
CView::OnMouseMove(nFlags, point);
}
}
else
;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -