Re: PolyLine and autoscrolling canvas
 
HI Stephen,
What happens with
                memDC.SetMapMode(MM_TEXT);
                dc.BitBlt(0,0,r.Width(),r.Height(),&memDC,0,0,SRCCPY);
???
Both memDC and dc are then using MM_TEXT, have the same size bitmaps, so
  this should work.  Is there something going on with bSetDraw?
Steve
           //Swap back the original bitmap.
           memDC.SelectObject(bOldBitmap);
   }
...
Figured out right a bit ago.... had to do:
1) put the grid drawing BEFORE the mapping
2) adding:
            memDC.SetWindowOrg(0, 0);
            memDC.SetViewportOrg(0, 0);
to re-set the point origin, probably because even if setting MM_TEXT
the point origin won't be reset to (0,0)...so the right OnPaint()
structure is this:
void CGraphClass::OnPaint()
{
        CPaintDC dc(this); // device context for painting
        CRect r;
        GetClientRect(&r);
        dc.SetBkColor(RGB(0,0,0));
        int saveobject = dc.SaveDC();
        if(bSetDraw)
        {
                // ********** Background ***********
                // Grid
                CDC memDC;
                CBitmap         bBitmap;                // Offscreen
bitmap
                CBitmap*        bOldBitmap;             // bitmap
originally found in CMemDC
                memDC.CreateCompatibleDC(&dc);
                bBitmap.CreateCompatibleBitmap(&dc, r.right,
r.bottom);
                bOldBitmap = memDC.SelectObject(&bBitmap);
                memDC.FillRect(r,
CBrush::FromHandle((HBRUSH)GetStockObject(BLACK_BRUSH)));
                if (bActivateGrid)
                {
                        CPen qLinePen(PS_SOLID, 1, RGB(0,139,0));
                        memDC.SelectObject(qLinePen);
                        // Grid - Horizontal lines
                        for(int y = 0; y < r.bottom; y += (int)12) {
                                /* scan y */
                                memDC.MoveTo(r.left, y);
                                memDC.LineTo(r.right,
y);
                        }       /* scan y */
                        // Grid - Vertical lines
                        for(int x = 0 - (int)gridOffset; x <= r.right
- (int)gridOffset; x += (int)12  ) {
                                /* scan x */
                                memDC.MoveTo(x, r.top);
                                memDC.LineTo(x, r.bottom);
                        }       /* scan x */
                }
                memDC.SetMapMode(MM_ANISOTROPIC);
                memDC.SetWindowExt(-r.right, iYMaxInterval);
                memDC.SetViewportExt(r.right, -r.bottom);
                memDC.SetWindowOrg(r.right, 0);
                memDC.SetViewportOrg(0, r.bottom);
                if (vtPoints.capacity() == 1)
                {
                        for (int i=vtPoints[0].size()-1;i>=0;i--) {
                                vtToDraw[0].at(i).x =
vtPoints[0].at(i).x;
                                vtToDraw[0].at(i).y =
( (vtPoints[0].at(i).y > 0) ? vtPoints[0].at(i).y : 86 );
                        }
                        //int savedraw = memDC.SaveDC();
                        CPen qPolylinePen(PS_SOLID, 1, RGB(0, 255,
0));
                        memDC.SelectObject(qPolylinePen);
                        vectfPoints* pointsline = &vtToDraw[0];
                        memDC.Polyline(&(*pointsline)[0],
(int)pointsline->size());
                        //dc.PolyPolyline()
                        //memDC.RestoreDC(savedraw);
                }
                // Copy the offscreen bitmap onto the screen.
                memDC.SetMapMode(MM_TEXT);
                memDC.SetWindowOrg(0, 0);
                memDC.SetViewportOrg(0, 0);
                // DC isn't altered about mapping!! so it should
SRCCOPY as like as the bitmap appears
                dc.BitBlt(r.left, r.top, r.right, r.bottom,
                        &memDC, r.left, r.top,
SRCCOPY);
                //Swap back the original bitmap.
                memDC.SelectObject(bOldBitmap);
        }
        dc.RestoreDC(saveobject);
}
Now I have to implement the vertical bars which it should be a bit
easier I think... at least there's always this place where to find
hints :-)
Thanks a lot for now
Ciao
Luigi