STL's experience (4) - Application (MFC)

zhaozj2021-02-12  136

Write a simple drawing program with MFC (I am afraid this should be more attention)

Only some of the code here:

The following source code can be run directly (VC6 MFC) (on its entire project file can go to www.confach.533.net to Download, if you can't find it, you can press the contact information directly with me Mil, I will be as soon as possible Send you past, everyone study together)

void CSTLMFCTestView :: OnLButtonDown (UINT nFlags, CPoint point) {// TODO: Add your message handler code here and / or call default SetCapture (); if (mPointVector.size () = 0!) {CClientDC dc (this); CSTLMFCTestDoc * pDoc = this-> GetDocument (); CPen lNewPen (PS_SOLID, pDoc-> m_iPenWidth, pDoc-> mColor); CPen * pOldPen = dc.SelectObject (& lNewPen); dc.MoveTo ((CPoint) mPointVector [mPointVector.size () -1]); DC.Lineto (POINT); pdoc-> setmodifiedflag (TRUE);} mpointVector.push_back (point); cview :: ONLBUTTONDOWN (NFLAGS, POINT);

void CSTLMFCTestView :: OnLButtonUp (UINT nFlags, CPoint point) {// TODO: Add your message handler code here and / or call default if (GetCapture () == this) ReleaseCapture (); CView :: OnLButtonUp (nFlags, point) }

void CSTLMFCTestView :: OnMouseMove (UINT nFlags, CPoint point) {// // TODO: Add your message handler code here and / or call default if ((nFlags & MK_LBUTTON) = MK_LBUTTON!) {return;} if (mPointVector.size () ! = 0) {CClientDC dc (this); CSTLMFCTestDoc * pDoc = this-> GetDocument (); CPen lNewPen (PS_SOLID, pDoc-> m_iPenWidth, pDoc-> mColor); CPen * pOldPen = dc.SelectObject (& lNewPen); dc .Moveto ((cpoint) MPointVector [MPOINTVector.Size () - 1]); DC.Lineto (Point); dc.selectObject (PoldPen); pdoc-> setmodifiedflag (TRUE);} mpointVector.push_back (point); cView: : OnMouseMove (NFLAGS, POINT);

转载请注明原文地址:https://www.9cbs.com/read-7068.html

New Post(0)