CScrollImpl::SetScrollSize()

There is a chance that both horizonal and vertical scroll bars are shown which are both unnecessary. If the desired size is smaller than the client without scroll bars, no scroll bar is needed. But before that call to SetScrollSize, both scroll bars are shown, so the client
size from GetClientRect is actual smaller than the real client area a window can provide. So two sroll bars are still shown which are both unnecessary.

This only happens when both scroll bars are shown. If vertical bar is hidden, then client area’s width is expanded which can hold actual width. Then the horizonal bar is also unneeded. Vice versa.

In MFC,there is a function called CScrollView::GetTrueClientSize()
This maybe helpful. WTL should “GetTrueClientSize” rather than listen to WM_SIZE.
>
One way to do this:

DWORD style = GetStyle();
int xTrue = m_sizeClient.cx;
int yTrue = m_sizeClient.cy;

if(style & WS_VSCROLL )
xTrue += ::GetSystemMetrics(SM_CXVSCROLL);

if(style & WS_HSCROLL )
yTrue += ::GetSystemMetrics(SM_CYHSCROLL);

// Auto fit zoom with image size known

float fxZoom = float(xTrue) / image.Width();
float fyZoom = float(yTrue) / image.Height();
Zoom(min(fxZoom, fyZoom));