|
-
April 28th, 1999, 10:00 AM
#1
Array of Points
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);
}
-
April 28th, 1999, 11:31 AM
#2
Re: Array of Points
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
#3
Re: Array of Points
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|