Date: | August 5, 2003 / year-entry #11 |
Tags: | code |
Orig Link: | https://blogs.msdn.microsoft.com/oldnewthing/20030805-00/?p=90531 |
Comments: | 0 |
Summary: | If you look at the WM_VSCROLL message, you'll see that the scroll position is a 16-bit value. So if the number of entries is more then 65535, you won't be able to use the scroll thumb to get to the ones at the end. Try it: Change the value of g_cItems to 100000 and watch... |
If you look at the WM_VSCROLL message, you'll see that the scroll position is a 16-bit
value. So if the number of entries is more then 65535, you won't be able to use the
scroll thumb to get to the ones at the end.
Try it: Change the value of g_cItems to 100000 and watch what happens.
The fix is to ignore the UINT GetTrackPos(HWND hwnd, int fnBar) { SCROLLINFO si; si.cbSize = sizeof(si); si.fMask = SIF_TRACKPOS; if (GetScrollInfo(hwnd, fnBar, &si)) { return si.nTrackPos; } return 0; }
Change the two case statements in case SB_THUMBPOSITION: ScrollTo(hwnd, GetScrollPos(hwnd, SB_VERT)); break; case SB_THUMBTRACK: ScrollTo(hwnd, GetTrackPos(hwnd, SB_VERT)); break; |