Maximum size of scrollbars
-
Does anyone know an easy way to overcome the problem with the SRT_MAX limit of scrollbars? :confused: -- modified at 12:08 Tuesday 7th March, 2006
-
This is my code:
void CEditor::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { SCROLLINFO ScrollInfo; ScrollInfo.cbSize = sizeof(SCROLLINFO); ScrollInfo.fMask = SIF_POS | SIF_RANGE; GetScrollInfo(SB_VERT, &ScrollInfo); switch(nSBCode){ ... case SB_THUMBPOSITION: ScrollInfo.nPos = nPos; break; case SB_THUMBTRACK: ScrollInfo.nPos = nPos; break; } SetVScroll(ScrollInfo.nPos); CWnd::OnVScroll(nSBCode, nPos, pScrollBar); }
The problem is that nPos does not become bigger than SRT_MAX. This is because nPos comes from the high-order word of the wParam of the message WM_VSCROLL. So it is just a short value that is casted to an integer. Is there another way to get the current position of the scroll box? Thanks -
This is my code:
void CEditor::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { SCROLLINFO ScrollInfo; ScrollInfo.cbSize = sizeof(SCROLLINFO); ScrollInfo.fMask = SIF_POS | SIF_RANGE; GetScrollInfo(SB_VERT, &ScrollInfo); switch(nSBCode){ ... case SB_THUMBPOSITION: ScrollInfo.nPos = nPos; break; case SB_THUMBTRACK: ScrollInfo.nPos = nPos; break; } SetVScroll(ScrollInfo.nPos); CWnd::OnVScroll(nSBCode, nPos, pScrollBar); }
The problem is that nPos does not become bigger than SRT_MAX. This is because nPos comes from the high-order word of the wParam of the message WM_VSCROLL. So it is just a short value that is casted to an integer. Is there another way to get the current position of the scroll box? ThanksYou have to initialize the scroll bar at some point with a call to
SetScrollInfo
. My guess would be you want to do this in yourCEditor::OnCreate
handler. ThenPos
value you are seeing in yourOnVScroll
handler varies between the values ofnMin
andnMax
in theSCROLLINFO
structure.
Software Zen:
delete this;
-
You have to initialize the scroll bar at some point with a call to
SetScrollInfo
. My guess would be you want to do this in yourCEditor::OnCreate
handler. ThenPos
value you are seeing in yourOnVScroll
handler varies between the values ofnMin
andnMax
in theSCROLLINFO
structure.
Software Zen:
delete this;
Thank you for your help, but I think I have to describe the problem more detailed. The scrollbar works fine when I move the scroll box with SB_PAGEDOWN or SB_LINEDOWN because in this case I do not need nPos. But when I react on SB_THUMBTRACK or SB_THUMBPOSITION I need nPos. So when I move the scroll box with the mouse to a position that is bigger than SRT_MAX nPos becomes zero and the scroll box jumps back to the top. Again: this is only the case if the scroll box is directly moved with the mouse. When I click on the scroll arrows everything works fine. So what I need is a way to find out where the user has moved the scroll box when it is above SRT_MAX. Thanks
-
Thank you for your help, but I think I have to describe the problem more detailed. The scrollbar works fine when I move the scroll box with SB_PAGEDOWN or SB_LINEDOWN because in this case I do not need nPos. But when I react on SB_THUMBTRACK or SB_THUMBPOSITION I need nPos. So when I move the scroll box with the mouse to a position that is bigger than SRT_MAX nPos becomes zero and the scroll box jumps back to the top. Again: this is only the case if the scroll box is directly moved with the mouse. When I click on the scroll arrows everything works fine. So what I need is a way to find out where the user has moved the scroll box when it is above SRT_MAX. Thanks
When handling
SB_THUMBTRACK
, you need to look at thenTrackPos
member of theSCROLLINFO
structure, notnPos
.
Software Zen:
delete this;
-
When handling
SB_THUMBTRACK
, you need to look at thenTrackPos
member of theSCROLLINFO
structure, notnPos
.
Software Zen:
delete this;