69,371
社区成员
发帖
与我相关
我的任务
分享
SCROLLINFO si;
...
...
si.cbSize = sizeof (si) ;
si.fMask = SIF_DISABLENOSCROLL |SIF_ALL ;
GetScrollInfo (hwndNP, SB_VERT, &si) ;//得到si.nPos=4
si.nPos += vp.iEndRow-vp.iStartRow ;//得到si.nPos=10
si.fMask = SIF_DISABLENOSCROLL |SIF_POS ;
SetScrollInfo (hwndNP, SB_VERT, &si, TRUE) ;//si.nPos=4
GetScrollInfo (hwndNP, SB_VERT, &si) ;//这里si.nPos又等于4了
si.nPos += vp.iEndRow-vp.iStartRow ;
//在这之前没有给si.nPage和si.nMax重新复制.
//导致si.nMax-si.nPage+1 < si.nPos ;
//Set不成功,不过没有报错:)
case WM_VSCROLL:
// Get all the vertical scroll bar information
si.cbSize = sizeof (si) ;
si.fMask = SIF_ALL ;
GetScrollInfo (hwnd, SB_VERT, &si) ;
// Save the position for comparison later on
iVertPos = si.nPos ;
switch (LOWORD (wParam))
{
case SB_TOP:
si.nPos = si.nMin ;
break ;
case SB_BOTTOM:
si.nPos = si.nMax ;
break ;
case SB_LINEUP:
si.nPos -= 1 ;
break ;
case SB_LINEDOWN:
si.nPos += 1 ;
break ;
case SB_PAGEUP:
si.nPos -= si.nPage ;
break ;
case SB_PAGEDOWN:
si.nPos += si.nPage ;
break ;
case SB_THUMBTRACK:
si.nPos = si.nTrackPos ;
break ;
default:
break ;
}
// Set the position and then retrieve it. Due to adjustments
// by Windows it may not be the same as the value set.
si.fMask = SIF_POS ;
SetScrollInfo (hwnd, SB_VERT, &si, TRUE) ;
GetScrollInfo (hwnd, SB_VERT, &si) ;
// If the position has changed, scroll the window and update it
if (si.nPos != iVertPos)
{
ScrollWindow (hwnd, 0, cyChar * (iVertPos - si.nPos),
NULL, NULL) ;
UpdateWindow (hwnd) ;
}
return 0 ;