Search code examples
cwinapiricheditwindows-controls

SetScrollRange Function


I've read about SetScrollRange but still didn't get what the range (min, max) is in scrollbar. I've set the rich edit control's vertical scroll bar range to (0, 100)

SetScrollRange(hwndRichEditControl, SB_VERT, 0, 100, TRUE);

Now, If I try GetScrollPos to get the position i'm getting the value over max range. Shouldn't the position be between 0 and 100?

int Pos = GetScrollPos(hwndRichEditControl, SB_VERT);

Solution

  • It shouldn't. The RichEdit control itself determines the scroll range of the scroll bar. Which it does depending on how much text it displays. Overriding it isn't going to last long, if at all. You can only use GetScrollInfo() to find out what it is using currently. This is going to change as soon as the user adds text.