// myscribbleView.cpp : implementation of the CMyscribbleView class
//

#include "stdafx.h"
#include "myscribble.h"

#include "myscribbleDoc.h"
#include "myscribbleView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyscribbleView

IMPLEMENT_DYNCREATE(CMyscribbleView, CView)

BEGIN_MESSAGE_MAP(CMyscribbleView, CView)
	//{{AFX_MSG_MAP(CMyscribbleView)
	ON_WM_LBUTTONDOWN()
	ON_WM_MOUSEMOVE()
	ON_WM_LBUTTONUP()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyscribbleView construction/destruction

CMyscribbleView::CMyscribbleView()
{
	// TODO: add construction code here
	startpt=-1;
	endpt=-1;
}

CMyscribbleView::~CMyscribbleView()
{
}

BOOL CMyscribbleView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CMyscribbleView drawing

void CMyscribbleView::OnDraw(CDC* pDC)
{
	CMyscribbleDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
}

/////////////////////////////////////////////////////////////////////////////
// CMyscribbleView diagnostics

#ifdef _DEBUG
void CMyscribbleView::AssertValid() const
{
	CView::AssertValid();
}

void CMyscribbleView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CMyscribbleDoc* CMyscribbleView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyscribbleDoc)));
	return (CMyscribbleDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMyscribbleView message handlers

void CMyscribbleView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	startpt.x=point.x;
	startpt.y=point.y;
	
	CView::OnLButtonDown(nFlags, point);
}

void CMyscribbleView::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CClientDC dc(this);
	endpt.x = point.x;
	endpt.y = point.y;
	if (startpt.x != -1 )
	{
		dc.MoveTo(startpt.x, startpt.y);
		dc.LineTo(endpt.x, endpt.y);
		startpt.x = endpt.x;
		startpt.y = endpt.y;
	}
	
	CView::OnMouseMove(nFlags, point);
}

void CMyscribbleView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	startpt = -1;
	
	CView::OnLButtonUp(nFlags, point);
}

