Click to See Complete Forum and Search --> : Array of Points


April 28th, 1999, 10:00 AM
New to VC++ and looking for kind person to assist me. Trying to create an array for a drawing program that will store up to 200 points as mouse moves across screen. Also need to serialize these points and maintain drawing when window is resized. Already have code for drawing done as shown below:

void CSimpleAppView::OnLButtonDown(UINT nFlags, CPoint point)
{
m_ptFrom = point;

if ((!m_bCaptured) && (m_bEnable))
{
m_bCaptured = TRUE;
SetCapture();
}

CView::OnLButtonDown(nFlags, point);
}

void CSimpleAppView::OnMouseMove(UINT nFlags, CPoint point)
{
if (m_bCaptured)
{
CClientDC dc(this);
CPen cPen;
cPen.CreatePen(PS_SOLID,1,m_Color);
CPen *pOldPen;
pOldPen = dc.SelectObject(&cPen);
dc.MoveTo(m_ptFrom);
dc.LineTo(point);
m_ptFrom = point;
}
CView::OnMouseMove(nFlags, point);
}

void CSimpleAppView::OnRButtonDown(UINT nFlags, CPoint point)
{
if (m_bCaptured)
{
ReleaseCapture();
m_bCaptured = FALSE;
m_bEnable = FALSE;
}

CView::OnRButtonDown(nFlags, point);
}

delbert Harry
April 28th, 1999, 11:31 AM
I would look up CArray and use that as an array to store your CPoint objects. Make sure to put the CArray variable in your Document or in your view(if SDI) and override the OnDraw function so that the lines will be redrawn when the view is redrawn.

April 28th, 1999, 01:30 PM
Thanks for your help !!! CArray looks like the ticket.
However, could you please explain a little further your comment about over-riding OnDraw (perhaps with code snippet to guide me)???

Again, many thanks.