CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Array of Points

  1. #1
    Guest

    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);
    }



  2. #2
    Join Date
    May 1999
    Posts
    92

    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.


  3. #3
    Guest

    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
  •  





Click Here to Expand Forum to Full Width

Featured