Original Post
I am using C++ with the Win32 API. I am loading one bitmap into the client area of a window. When the bitmap is larger than the client area, I need scroll bars. When the window is sized, and it is larger than the bitmap, I don't need the bars, but when it is sized and it is smaller than the bitmap, I need to create scroll bars. Everything seems to be working fine except that they are triggering off and on at the incorrect position. Here is how I handle WM_SIZE, almost exactly what MSDN does in their "How to scroll a bitmap" article: They tigger on and off at about half way through the bitmap. Another odd find is that when I set the page to 0, it triggers at the correct position, but then the size of the bar is a constant small. When the page is set to the client width or height, then it grows and shrinks as you size it, like it should. Does anyone know how I can fix this problem? Any help is appreciated. Thank you, -Dev578
case WM_SIZE:
{
int nHMax = max(FontCreator.m_nBmpWidth - LOWORD(lParam),0);
int nHPage = LOWORD(lParam);
SCROLLINFO si = {0};
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE | SIF_POS;
si.nMax = nHMax;
si.nMin = 0;
si.nPage = nHPage;
si.nPos = cur_xpos;
SetScrollInfo(hWnd, SB_HORZ, &si, true);
//then I do the same for the vertical scroll bar
}
break;