CompuServe Thread

#Scroller-mod. view size?

2 messages in this thread
#30535From: Brad PirtleJul 11, 1994 1:40 PM
I want to enhance an app based on the CScrollView class. What I want is to add zoom in, zoom out capabilities. With my basic understanding of the CScrollView class, it supports a changing Doc size, but a fixed View size (relative to the actual window size). Is there any way to make the view size "virtual" also? i.e., the window may be 50×50 pixels, but it displays a 100×100 region of the document. Obviously scaling of the drawing would be nescesary, possible during the DPtoLP and LPtoDP routines. Any ideas/suggestions?? I've done this before in an all Windows SDK app, but am wondering of an automatic and cool MFC method! I would like to think that this was thought of when the CScrollView class was born. Thanks in advance, BP
#30614From: Gary CappsJul 11, 1994 10:45 PM
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?"