CompuServe Messages

Scroller-mod. view size?

    11-Jul-94 22:45:29
Fm: Gary Capps 74634,3377
To: Brad Pirtle 72450,1156
BP> I want to enhance an app based on the CScrollView BP> class. What I want is to add zoom in, zoom out capabilities. I did this for an application that displays CAD-type entitiy lists which had to be mapped from real-world coordinates to GDI's 16 bit integer coordinate space. An excellent reference to GDI zooming is Bob Chiverton's chapter in MS Press's _Windows 3.1 Developer's Workshop_. Although his example is in C and uses fixed zoom scales (I needed AutoCAD-like "smooth" zooming), I found it extremely useful. Because I also needed independently zoomable and scrollable views in the CSplitterWnd's panes, I derived my view class from CView instead of CScrollView. To handle the zooming, scrolling, and coordinate transformations, I created a "CZoomer" class and embedded a member in the view. The view then simply passed all mouse clicks, movement, and scroll bar messages to the zoomer, which did all the hard work. Something like this… void CGrafixView::OnLButtonDown(UINT nFlags, CPoint point) { CView::OnLButtonDown(nFlags, point); m_zoomer.Pick( point ); // start tracking zoom box } void CGrafixView::OnLButtonUp(UINT nFlags, CPoint point) { if ( m_zoomer.IsTracking() && m_zoomer.Pick( point ) ) // i.e. zoom successful QueueRedraw(); CView::OnLButtonUp(nFlags, point); } A third class, CTMX, encapsulated the transformation matrixes needed to convert world coordinates to/from GDI. These were embedded in and maintained by the zoomer. The display was updated by traversing the entity list like this… int nCount = m_pEList->GetCount(); CEntity *pEntity; for ( m_listIndex = 0; m_listIndex < nCount; m_listIndex++ ) { pEntity = (*m_pEList)[ m_listIndex ]; // each entity type (line, circle, block, etc.) is derived from single root // CEntity class and overloads the virtual function Render() to draw itself // with the provided CDC and transformation matrix pEntity->Render( pDC, m_zoomer.WorldToLogical() ); } Well, I don't know if any of that made any sense or applies to your situation, but that's how I approached it. gc Norman, Oklahoma USA — "Is that a *real* poncho or is that a *Sears* poncho?"