为什么我在程序初始化时:
SCROLLINFO info;
info.cbSize = sizeof(SCROLLINFO);
info.fMask = SIF_ALL;
info.nMin = 0;
info.nMax = 50;
info.nPage = 5;
info.nPos = 10;
info.nTrackPos = 1;
m_ScrollBar.SetScrollInfo(&info);而当点击滚动条,产生消息时:
OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default// Get the minimum and maximum scroll-bar positions.
int minpos;
int maxpos;
int maxpos1;
m_scbVert.GetScrollRange(&minpos, &maxpos);
maxpos1 = m_scbVert.GetScrollLimit();为什么:
此时minpos=0, maxpos=50
而maxpos1 =31
为什么:maxpos与maxpos1不相等。
怎样才能使maxpos1等于maxpos。我本意是想点击50次,滚动条才到达底端,可现在点击33次就到达底端了,改怎样避免这种情况你。也就是实现点击50次才到达底端。
SCROLLINFO info;
info.cbSize = sizeof(SCROLLINFO);
info.fMask = SIF_ALL;
info.nMin = 0;
info.nMax = 50;
info.nPage = 5;
info.nPos = 10;
info.nTrackPos = 1;
m_ScrollBar.SetScrollInfo(&info);而当点击滚动条,产生消息时:
OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// TODO: Add your message handler code here and/or call default// Get the minimum and maximum scroll-bar positions.
int minpos;
int maxpos;
int maxpos1;
m_scbVert.GetScrollRange(&minpos, &maxpos);
maxpos1 = m_scbVert.GetScrollLimit();为什么:
此时minpos=0, maxpos=50
而maxpos1 =31
为什么:maxpos与maxpos1不相等。
怎样才能使maxpos1等于maxpos。我本意是想点击50次,滚动条才到达底端,可现在点击33次就到达底端了,改怎样避免这种情况你。也就是实现点击50次才到达底端。
info.cbSize = sizeof(SCROLLINFO);
info.fMask = SIF_ALL;
info.nMin = 0;
info.nMax = 50;
info.nPage = 5;
info.nPos = 10;
info.nTrackPos = 1;
m_ScrollBar.SetScrollInfo(&info);你的这段代码有问题, 把nPos改为0,
nMin
Specifies the minimum scrolling position.
nMax
Specifies the maximum scrolling position.
nPage
Specifies the page size. A scroll bar uses this value to determine the appropriate size of the proportional scroll box.
nPos
Specifies the position of the scroll box.
nTrackPos
Specifies the immediate position of a scroll box that the user is dragging. An application can retrieve this value while processing the SB_THUMBTRACK request code. An application cannot set the immediate scroll position; the SetScrollInfo function ignores this member.
The maximum value that a scroll bar can report (that is, the maximum scrolling position) depends on the page size. If the scroll bar has a page size greater than one, the maximum scrolling position is less than the maximum range value. You can use the following formula to calculate the maximum scrolling position:MaxScrollPos = MaxRangeValue - (PageSize - 1) msdn上说的很明白.