views:

273

answers:

0

I have another question open regarding an error I'm experiencing with the horizontal scrollbar of a RichTextBox not functioning properly and am not getting much response. It came to me that I might be asking the wrong question.

My new question is how do the scrollbar properties get set/controlled. I know I can SendMessage to change them but I'm wondering about the "automatic" stuff that occurs.

For instance when I start typing in a RichEdit / RichTextBox control the scrollbars will start in a disabled state. As the text moves beyond the edge of the control the scollbar becomes enabled. As the distance "off control" increases the scrollbar grab handle becomes shorter.

I'm not sure if the RichTextBox control is actually checking these properties and sending a message to, for instance, make the scrollbar grab handle become shorter. Or if it's more of an automatic process?

If it's an automatic process then I wonder if there is a message I could send that would make the control "recaculate" these properties.

Edit:

After researching this more I assume the RichtTextBox control is executing SetScrollRange() or `SetScrollInfo() when the control is resized and passing an incorrect value. I'm trying to use Reflector to see how and when the RichTextBox calls either of these methods but I'm not having much luck so far.

Edit:

Using GetScrollInfo() to dig into this more. When the control first starts the values are:

[5312] RTBE: Resize - ScrollInfo: Max: 7793 Min: 0 Page: 977 Pos: 0 TrackPos: 0 || RichtTextBox.RightMargin == 0 || RichTextBox.WordWrap == WrapToPrintDocument / False

I resize and the problem occurs. Keep resizing until the text wrapped by my EM_SETTARGETDEVICE call actually runs off the edge of the screen. At that point GetScrollInfo() returns the following which looking more reasonable:

[5312] RTBE: Resize - ScrollInfo: Max: 618 Min: 0 Page: 616 Pos: 0 TrackPos: 0 || RichtTextBox.RightMargin == 0 || RichTextBox.WordWrap == WrapToPrintDocument / False

I'm sure it is something inside the RichTextBox control that is fighting me but what? I'll keep playing :-)

Edit:

I think I'm on the right track (see my answer to my previous question) but it's a hack and I'm still not sure where/how the RichTextBox is setting the SCROLLINFO parameters from. I think if I could figure this out I'd be much closer to making the RichTextBox do what I want without the need for a "fix" message.