0

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);
Jack
  • 3
  • 2

1 Answers1

1

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.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • But how may I know if the scrollpos at the middle or bottom? – Jack Jan 15 '11 at 14:12
  • That's not a complete sentence, I have to guess that you are indeed talking about the info you get out of GetScrollInfo(). You get a SCROLLINFO with nMin, nMax and nPos. The nPos value tells you where it is scrolled, relative to nMin and nMax. – Hans Passant Jan 15 '11 at 14:25
  • Actually that is what is the problem, I don't get a nPos value relative to nMin and nMax. it goes over nMax. – Jack Jan 15 '11 at 14:45
  • The thumb of a vertical scrollbar has *two* edges, top and bottom. SCROLLINFO.nPage tells you how large the thumb is. – Hans Passant Jan 15 '11 at 14:57
  • Thanks maybe you mean i need to calculate it myself. – Jack Jan 15 '11 at 15:10