home *** CD-ROM | disk | FTP | other *** search
- // drawivw.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "drawit.h"
- #include "drawivw.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CDrawitView
-
- IMPLEMENT_DYNCREATE(CDrawitView, CFormView)
-
- CDrawitView::CDrawitView()
- : CFormView(CDrawitView::IDD)
- {
- //{{AFX_DATA_INIT(CDrawitView)
- m_NumberOfMoves = 0;
- //}}AFX_DATA_INIT
- }
-
- CDrawitView::~CDrawitView()
- {
- }
-
- void CDrawitView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CDrawitView)
- DDX_Text(pDX, IDC_EDIT1, m_NumberOfMoves);
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CDrawitView, CFormView)
- //{{AFX_MSG_MAP(CDrawitView)
- ON_WM_MOUSEMOVE()
- ON_WM_LBUTTONDOWN()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CDrawitView message handlers
-
-
- void CDrawitView::OnMouseMove(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
-
- if ( (nFlags & MK_LBUTTON) == MK_LBUTTON )
- {
- // This code is executed provided that:
- // 1. The mouse moved inside the client area.
- // 2. The left button of the mouse was pushed down.
-
- // Create a dc object
- CClientDC dc(this);
-
- // dc.SetPixel(point.x, point.y, RGB(0,0,0));
-
- dc.MoveTo(m_PrevX, m_PrevY);
- dc.LineTo(point.x, point.y);
- m_PrevX = point.x;
- m_PrevY = point.y;
-
- // Increment the counter
- m_NumberOfMoves++;
-
- // Update the screen
- UpdateData(FALSE);
-
- }
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- CFormView::OnMouseMove(nFlags, point);
- }
-
- void CDrawitView::OnLButtonDown(UINT nFlags, CPoint point)
- {
- // TODO: Add your message handler code here and/or call default
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- m_PrevX = point.x;
-
- m_PrevY = point.y;
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- CFormView::OnLButtonDown(nFlags, point);
- }
-