CodePudding user response:
My main code is as follows: : ://MFCApplication2View. CPP: CMFCApplication2View class the implementation of the
//
# include "stdafx. H"
//SHARED_HANDLERS can achieve in the preview, thumbnails and search filter handle
//ATL project are defined, and allow the code to share with the project document,
# # ifndef SHARED_HANDLERS
# include "MFCApplication2. H"
# endif
# include "MFCApplication2Doc. H"
# include "MFCApplication2View. H"
# ifdef _DEBUG
# define new DEBUG_NEW
# endif
Int m_DrawType;
CPoint m_End;
CPoint m_ptOrigin;
//CMFCApplication2View
IMPLEMENT_DYNCREATE (CMFCApplication2View, CView)
BEGIN_MESSAGE_MAP (CMFCApplication2View, CView)
//standard print command
ON_COMMAND (ID_FILE_PRINT, & amp; The CView: : OnFilePrint)
ON_COMMAND (ID_FILE_PRINT_DIRECT, & amp; The CView: : OnFilePrint)
ON_COMMAND (ID_FILE_PRINT_PREVIEW, & amp; The CView: : OnFilePrintPreview)
ON_COMMAND (ID_32771, & amp; CMFCApplication2View: : OnLine)
ON_COMMAND (ID_32772, & amp; CMFCApplication2View: : OnRectangle)
ON_COMMAND (ID_32773, & amp; CMFCApplication2View: : OnEllipse)
ON_COMMAND (ID_32774, & amp; CMFCApplication2View: : OnColor)
ON_COMMAND (ID_32775, & amp; CMFCApplication2View: : OnSetting)
ON_WM_LBUTTONDOWN ()
ON_WM_LBUTTONUP ()
END_MESSAGE_MAP ()
//CMFCApplication2View structure/destructor
CMFCApplication2View: : CMFCApplication2View ()
{
//TODO: add construction code here
}
CMFCApplication2View: : ~ CMFCApplication2View ()
{
}
BOOL CMFCApplication2View: : PreCreateWindow (CREATESTRUCT& Cs)
{
//TODO: here by modifying the
//cs to modify the CREATESTRUCT window class or style
Return the CView: : PreCreateWindow (cs);
}
//CMFCApplication2View map
Void CMFCApplication2View: : ontouch pDC (CDC */* */)
{
CMFCApplication2Doc * pDoc=GetDocument ();
ASSERT_VALID (pDoc);
if (! PDoc)
return;
//TODO: here is the machine data add rendering code
}
//print CMFCApplication2View
BOOL CMFCApplication2View: : OnPreparePrinting (CPrintInfo * pInfo)
{
//the default to
Return DoPreparePrinting (pInfo);
}
Void CMFCApplication2View: : OnBeginPrinting (CDC, pDC */* */pInfo CPrintInfo */* */)
{
//TODO: add additional print before initialization process
}
Void CMFCApplication2View: : OnEndPrinting (CDC, pDC */* */pInfo CPrintInfo */* */)
{
//TODO: add print after the cleaning process of
}
//CMFCApplication2View diagnosis
# ifdef _DEBUG
Void CMFCApplication2View: : AssertValid (const)
{
The CView: : AssertValid ();
}
Void CMFCApplication2View: : Dump (CDumpContext& Dc) const
{
The CView: : Dump (dc);
}
Const CMFCApplication2Doc * CMFCApplication2View: : GetDocument ()//a debug version is inline
{
ASSERT (m_pDocument - & gt; IsKindOf (RUNTIME_CLASS (CMFCApplication2Doc)));
Return (CMFCApplication2Doc *) m_pDocument;
}
# endif//_DEBUG
//CMFCApplication2View message handler
Void CMFCApplication2View: : OnLine ()
{
//TODO: add the command handler code
M_DrawType=1;
}
Void CMFCApplication2View: : OnRectangle ()
{
//TODO: add the command handler code
M_DrawType=2;
}
Void CMFCApplication2View: : OnEllipse ()
{
//TODO: add the command handler code
M_DrawType=3;
}
Void CMFCApplication2View: : OnColor ()
{
//TODO: add the command handler code
}
Void CMFCApplication2View: : OnSetting ()
{
//TODO: add the command handler code
}
Void CMFCApplication2View: : OnLButtonDown (UINT nFlags, CPoint point)
{
//TODO: add the message handler code and/or invoke the default
M_ptOrigin=point;
The CView: : OnLButtonDown (nFlags, point);
}
Void CMFCApplication2View: : OnLButtonUp (UINT nFlags, CPoint point)
{
//TODO: add the message handler code and/or invoke the default
CClientDC dc (this);//create a dc
CPen pen (PS_SOLID, 1, RGB (0, 255));//create the drawing brushes
CBrush * pbrush=CBrush: : FromHandle ((HBRUSH) GetStockObject (NULL_BRUSH));//create drawing fill brush
Dc. SelectObject (& amp; Pen);//will brush and brush for equipment described in the table
Dc. SelectObject (pbrush);
The switch (m_DrawType)//according to the drawing to draw
{
Case 1:
Dc. MoveTo (m_ptOrigin);
Dc. LineTo (point);
break;
Case 2:
Dc. A Rectangle (CRect (m_ptOrigin, point));
break;
Case 3:
Dc. The Ellipse (CRect (m_ptOrigin, point));
break;
Default:
break;
}
The CView: : OnLButtonUp (nFlags, point);
}
CodePudding user response:
List in memory of the next value is memory addressList is the value of the next file offset in the file
CodePudding user response:
1, the drawing operation, the mouse movement, must use the appropriate data structure to save the data, rather than directly onto the screenTypically OnLButtonDown action function, such as does not contain the
GDI drawing function2, after the operation call Invalidate the
3, shall be the responsibility of the ontouch according to 1 or loaded from the disk data painting
CodePudding user response:
Yes, I use OnLButtonDown drawing action function, such as card on this save, thank you for your advicenullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull