1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| void CFenetreDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
int minpos;
int maxpos;
GetScrollRange(SB_VERT, &minpos, &maxpos);
maxpos = GetScrollLimit(SB_VERT);
// Get the current position of scroll box.
int curpos = GetScrollPos(SB_VERT);
// Determine the new position of scroll box.
switch (nSBCode)
{
case SB_TOP: // Scroll to far top.
curpos = minpos;
break;
case SB_BOTTOM: // Scroll to far bottom.
curpos = maxpos;
break;
case SB_ENDSCROLL: // End scroll.
break;
case SB_LINEUP: // Scroll up.
if (curpos > minpos)
curpos--;
break;
case SB_LINEDOWN: // Scroll down.
if (curpos < maxpos)
curpos++;
break;
case SB_PAGEUP: // Scroll one page ip.
{
// Get the page size.
SCROLLINFO info;
GetScrollInfo(SB_VERT, &info, SIF_ALL);
if (curpos > minpos)
curpos = max(minpos, curpos - (int) info.nPage);
}
break;
case SB_PAGEDOWN: // Scroll one page down.
{
// Get the page size.
SCROLLINFO info;
GetScrollInfo(SB_VERT, &info, SIF_ALL);
if (curpos < maxpos)
curpos = min(maxpos, curpos + (int) info.nPage);
}
break;
case SB_THUMBPOSITION: // Scroll to absolute position. nPos is the position
curpos = nPos; // of the scroll box at the end of the drag operation.
break;
case SB_THUMBTRACK: // Drag scroll box to specified position. nPos is the
curpos = nPos; // position that the scroll box has been dragged to.
break;
}
// Set the new position of the thumb (scroll box).
SetScrollPos(SB_VERT, curpos);
CDialogEx::OnVScroll(nSBCode, nPos, pScrollBar);
} |
Partager