//
# include "stdafx. H"
# include "drawing. H
"
# include "drawing Doc. H"
# include "drawing the h
"# include "SettingDlg. H"
#include
# ifdef _DEBUG
# define new DEBUG_NEW
# undef THIS_FILE
The static char THIS_FILE []=__FILE__;
# endif
/////////////////////////////////////////////////////////////////////////////
//CMyView
IMPLEMENT_DYNCREATE (CMyView, CView)
BEGIN_MESSAGE_MAP (CMyView, CView)
//{{AFX_MSG_MAP (CMyView)
ON_COMMAND (IDM_LINE, OnLine)
ON_COMMAND (IDM_RECTANGLE OnRectangle)
ON_COMMAND (IDM_Circle OnCircle)
ON_COMMAND (IDM_Random_Line OnRandomLine)
ON_COMMAND (IDM_POLYGON OnPolygon)
ON_WM_LBUTTONUP ()
ON_WM_LBUTTONDOWN ()
ON_WM_MOUSEMOVE ()
ON_WM_RBUTTONDOWN ()
ON_WM_RBUTTONUP ()
ON_COMMAND (IDM_SET_COLOR OnSetColor)
ON_COMMAND (IDM_SET_LINE_STYLE_WIDTH OnSetLineStyleWidth)
//}} 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 ()
/////////////////////////////////////////////////////////////////////////////
//CMyView construction/destruction
CMyView: : CMyView ()
{
//TODO: add construction code here
M_nDrawType=0;
M_ptOrigin=0;
M_nLineStyle=0;
M_nLineWidth=1;
M_dcMetaFile. The Create ();
No1=0;
No2=0;
No3 -=0;
No.4=0;
No5=0;
k=0;
}
CMyView: : ~ CMyView ()
{
}
BOOL CMyView: : PreCreateWindow (CREATESTRUCT& Cs)
{
//TODO: Modify the Window class or styles here by modifying the
//the CREATESTRUCT cs
Return the CView: : PreCreateWindow (cs);
}
/////////////////////////////////////////////////////////////////////////////
BOOL CMyView: : OnPreparePrinting (CPrintInfo * pInfo)
{
//the default preparation
Return DoPreparePrinting (pInfo);
}
Void CMyView: : OnBeginPrinting (CDC, pDC */* */pInfo CPrintInfo */* */)
{
//TODO: add extra initialization before printing
}
Void CMyView: : OnEndPrinting (CDC, pDC */* */pInfo CPrintInfo */* */)
{
//TODO: add the cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
//CMyView diagnostics
# ifdef _DEBUG
Void CMyView: : AssertValid (const)
{
The CView: : AssertValid ();
}
Void CMyView: : Dump (CDumpContext& Dc) const
{
The CView: : Dump (dc);
}
CMyView CMyDoc * : : GetDocument ()//non - the debug version is the inline
{
ASSERT (m_pDocument - & gt; IsKindOf (RUNTIME_CLASS (CMyDoc)));
Return (CMyDoc *) m_pDocument;
}
# endif//_DEBUG
/////////////////////////////////////////////////////////////////////////////
//CMyView message handlers
//DEL void CMyView: : OnUpdateLine (CCmdUI * pCmdUI)
//DEL {
//DEL//TODO: Add your command update the UI handler code here
//DEL
//DEL}
Void CMyView: : OnLine ()
{
//TODO: Add your command handler code here
M_nDrawType=1;
}
Void CMyView: : OnRectangle ()
{
//TODO: Add your command handler code here
M_nDrawType=2;
}
Void CMyView: : OnCircle ()
{
//TODO: Add your command handler code here
M_nDrawType=3;
}
Void CMyView: : OnRandomLine ()
{
//TODO: Add your command handler code here
M_nDrawType=4;
}
Void CMyView: : OnPolygon ()
{
//TODO: Add your command handler code here
M_nDrawType=5;
}
Void CMyView: : OnLButtonUp (UINT nFlags, CPoint point)
{
The CView: : OnLButtonUp (nFlags, point);
}
Void CMyView: : OnLButtonDown (UINT nFlags, CPoint point)
{
//TODO: Add your message handler code here and/or call the default
CClientDC dc (this);
CPoint point1, point2;
M_ptOrigin=point;
CMyDoc * pDoc=GetDocument ();
If (m_nDrawType==4)
{
PDoc - & gt; Pointduo [k]=point;
K++;
}
If (m_nDrawType==5)
{
PDoc - & gt; Pointp [k]=point;
K++;
}
If (no1 | | no2 | | no3)
{
The switch (m_nDrawType)
{
Case 1: if (no1==1) no1=0; break;
Case 2: if (no2==1) no2=0; break;
Case 3: if no3 - (no3 -==1)=0; break;
}
}
Else if (m_nDrawType!=0)
{
If (m_nDrawType!
=3){
CPen pen (0, 1, m_color);
CPen * pOldPen=dc. SelectObject (& amp; Pen);
Point1. X=point. X + 5;
Point1. Y=point. Y + 5;
Point2. X=point. X - 5;
Point2. Y=point. Y - 5;
Dc. The Ellipse (CRect (point1, point2));
}
The switch (m_nDrawType)
{
Case 1: no1=1;
break;
Case 2: no2=1;
break;
Case 3: no3=1;
break;
Case 4: no.4=1;
break;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull