I'm learning on my own how drawing icons, scaling, and scrolling using Visual C++. My project is to place any icon in the child window, zoom in or out, and scroll anywhere. I am able to place icons with a rectangle around the icon, zoom in (out is just as easy and I'll include it later), BUT I can't scroll. The scroll bars will change size as I zoom in. However, the scroll bars don't scroll but return to their original location after I try to drag them even though they change size depending on the scale I'm using. What can I do? I included the relevant parts of code in CScrollView as I don't use the CDocument or anything else.

I right click to zoom in use the OnRButton message:

// Increment the scale to zoom in and set the scrollbar size
void CME6View::OnRButtonUp(UINT nFlags, CPoint point)
CClientDC theCDC(this);

CScrollView::OnRButtonUp(nFlags, point);

Here's my OnPrepareDC code. I use GetClipBox to cause window extent to be the size of visible window instead of a CSize variable in the document as most examples use. I make sure to subtract the BottomRight from the TopLeft so that the BottomRight is larger than normal in the I have scrolled as in VRx and VRy.

void CME6View::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
CScrollView::OnPrepareDC(pDC, pInfo);

CME6Doc* pDoc = GetDocument();

pDC->GetClipBox(m_VisRect);// Visible rectangles in pixels

int VRx = m_VisRect.BottomRight().x - m_VisRect.TopLeft().x;
int VRy = m_VisRect.BottomRight().y - m_VisRect.TopLeft().y;


int PpIX = pDC->GetDeviceCaps(LOGPIXELSX);// pixels / inch - x
int PpIY = pDC->GetDeviceCaps(LOGPIXELSY);// pixels / inch - y

// Calculating the window
int WEx = VRx / PpIX;
if(WEx < 1) // To prevent the window extent x-coord from being zero
WEx = 1;
int WEy = VRy / PpIY;
if(WEy < 1) // To prevent the window extent y-coord from being zero
WEy = 1;

// Calculating the viewport extent
int VEx = WEx * m_Scale;
int VEy = WEy * m_Scale;

// For troubleshooting
//AfxMessageBox(_T("ClipBox: " + ToStringI(VRx) + ", " + ToStringI(VRy) + "\npixels / inch: " + ToStringI(PpIX) + ", " + ToStringI(PpIY) + "\nWE: " + ToStringI(WEx) + ", " + ToStringI(WEy) + "\nVE: " + ToStringI(VEx) + ", " + ToStringI(VEy)), MB_OK);

pDC->SetWindowExt(WEx, WEy);
pDC->SetViewportExt(VEx, VEy);

This is how I set the scroll bar sizes:

// Set the scroll bars
void CME6View::SetScrolling()
SetScrollSizes(MM_TEXT, CSize((m_VisRect.BottomRight().x - m_VisRect.TopLeft().x) * m_Scale, (m_VisRect.BottomRight().y - m_VisRect.TopLeft().y) * m_Scale));

I had oringially used OnInitialUpdate but I have left it blank to set up scrollbars after zooming

// Not using this as it's not initially important
void CME6View::OnInitialUpdate()

Please help.