Breaking the CScrollView 32768 size limitation with CBigScrollView
Extending the scroll size capability.
To surpass the limitation of CScrollView, it is possible to calculate a new CBigScrollView size that surpass the limitation of 32768 and calculate the origin of the CScrollView inside this new virtual size.
Using CScrollView to scroll, the client size moves only into CScrollView size. Reaching the sides of CScrollView size, the CScrollSize moves into CBigScrollView size. The only problem doing this it that the scroll bars doesn't reflect the CBigScrollView size but the CScrollSize instead. This is acceptable else it is necessary to rewrite entirely CScrollView. Zoom is limited to 2,147,483,648/2960=725.50.
CBigScrollView has the same properties than CScrollView. You can set the mapping mode like CScrollView. CBigScrollView doesn't use float type but only long type. No float arithmetic is made.
A problem using GDI functions is that clipping is doing only in valid range. When you draw a line into virtual range, you are responsible to clip the line into valid range like client rectangle or CScrollView size. This sample implements a line-clipping algorithm.
Using CBigScrollView to Zoom into the view.
This sample use CBigScrollView to implement a CAppScrollView view with Zoom capabilities. MM_LOMETRIC is used as mapping mode but you can use any valid mapping mode.
A problem zooming into the view is that the user expects that the center of the client size remains the same. To do this, it is necessary to save the center of the client size before zooming and restore it after this. This is true also when resizing the window.
This sample implements Zoom In, Zoom Out, Zoom Default, Zoom with rectangle and hand move functions. In Hand mode, when pressing the left mouse button, you can move the view. In the other mode selected with the toolbar or the right button, you can select a zooming rectangle.
Changing document size with Printer setup.
For true graphic applications, it is necessary to set the document size according to the printer paper size. This sample reflects exactly the paper size. If you change the orientation or the paper size, a message is send to the document to update views.
Download demo application (without source)- 15 KB
Date Last Updated: February 14, 1999

Comments
CMyiew (this is all you have to do
Posted by Legacy on 11/21/2003 12:00amOriginally posted by: youfenman
ReplyBigScrl still doesn't scroll correctly
Posted by Legacy on 07/31/2003 12:00amOriginally posted by: Tim
This program still has a problem with scrolling, so I don't know how it's going to help anyone. When you zoom in beyond the 32K limit, and then you try to scroll to the edges, you can't. You're forced to use the grabby hand, and then the scroll bars reposition and allow you to continue scrolling to the hidden edge. Try it!
Does anyone know how to make it so you can zoom all the way in and scroll to all four edges using only the scroll bars?
ReplyDrawing problems
Posted by Legacy on 05/15/2003 12:00amOriginally posted by: Sabotto Massimo
Very very Great work! Thank you for sharing the code.
I'm experiencing problems on using your class in an MFC app.
I only substituted your demo drawing code with GDI+ functions that draw images on screen. Nothing appears!.
The drawing function return success so I think I'm doing something wrong but I don't know what and where!
Have you got some ideas or any suggestions?
Should your class work with any system metrics?
Thank you in advance
Massimo
ReplyFix when scroll bars are hidden
Posted by Legacy on 04/24/2003 12:00amOriginally posted by: Mark Husted
Great piece of work! It truly saved me a lot of time to get the type of functionality that you have here.
I did find one problem; when you maximize the screen and the horizontal scrool bar is hidden, you could still grab the image with the HandTracker and move it horizontally. It does not crash, but it does mess up the picture. I found the problem and provide a solution.
It appears that when the screen is maximized, the scroll bar is hidden, but not disabled. Thus if you start tracking around the screen the MS CScrollView code still believes that there is a horizontal scroll bar with the size set to the last value when it was visible.
The solution was to duplicate some code that is buried in CScrollView in the CBigScrollView::OnSize function that tests to see if the scroll bars are needed. If they are not, then I update the scroll bar info with the new size. It is not the cleanest solution, but it works.
I pasted the modified OnSize function below:
void CBigScrollView::OnSize(UINT nType, int cx, int cy)
{
CScrollView::OnSize(nType, cx, cy);
///////////////////////////////////
//
// added to help determine if the scrollbar
CPoint ptMove;
CSize needSb;
CSize sizeRange;
CSize sizeClient;
CSize sizeSb;
GetTrueClientSize(sizeClient, sizeSb) ;
// get the current scroll bar state given the true client area
GetScrollBarState(sizeClient, needSb, sizeRange, ptMove, TRUE);
if( !needSb.cx )
{
SCROLLINFO info;
info.fMask = SIF_PAGE|SIF_RANGE;
info.nMin = 0;
info.nPage = sizeClient.cx;
info.nMax = m_totalDev.cx-1;
SetScrollInfo(SB_HORZ, &info, TRUE);
}
if( !needSb.cy )
{
SCROLLINFO info;
info.fMask = SIF_PAGE|SIF_RANGE;
info.nMin = 0;
info.nPage = sizeClient.cy;
info.nMax = m_totalDev.cy-1;
SetScrollInfo(SB_VERT, &info, TRUE) ;
}
//
// END ADDED CODE
////////////////////////////////////////////
// if ScrollView is not initialized, exit
if (m_nMapMode == MM_NONE) return;
// if changing size, restore client center
if (nType == SIZE_RESTORED || nType == SIZE_MAXIMIZED)
if (IsWindowVisible())
RestoreClientCenter();
}
If you add this, it will help the viewed area behave a little better.
ReplyInitial value for CBigScrollview
Posted by Legacy on 11/13/2001 12:00amOriginally posted by: Natz
Great source for standard application that uses any paper size as the inital document size.
ReplyFor my application i need the size of the actual view as the inital document size. So my output has always the extention of the view or if it is zoomed it is bigger. Resizing the view means to resizing m_sizeDoc. I've made a lot of tests but i get no good result.
It would be nice if you can give me a short tip how i can change your source so that the inital m_sizeDoc is not a value of a papersize but of the viewsize.
It is possible to load image using the view
Posted by Legacy on 03/20/2000 12:00amOriginally posted by: Venkatesh N.K.
Please help me to load image(BMP)using this (Zoomin & Zoomout) option with scrollview
ReplyProject is not full
Posted by Legacy on 01/28/2000 12:00amOriginally posted by: VOX
Where are THE HEADER's files?
ReplyAbout Scroll function
Posted by Legacy on 05/27/1999 12:00amOriginally posted by: John
ReplyOnly 16bit problem
Posted by Legacy on 02/15/1999 12:00amOriginally posted by: ray auchterlounie
This limit to +/- 32k for coordinates only affects 16bit Windows - which unfortunately includes 95/98 (this is just one of many indications that they are still 16bit).
On NT / Windows2000 the limits are +/- 2GB.
Also it should perhaps be noted that _all_ GDI coordinates (not just line drawing as mentioned in the article) need to be clipped if outside the valid range - otherwise the 16bit GDI layers will simply truncate them into the valid range, which won't be the desired result.
ray
Reply