Hello everyone...

I'm having a problem with RichEdit and its default scrolling behaviour.

When a new line is added to a RichEdit (via a Timer OnTimer event), it autoscrolls to the bottom, which is fine. The problem is, while it scrolls to bottom, it also resets the horizontal scrollbar to the left, which is undesirable because I want to view the end of my messages.

I've tried to detect SB_LEFT, SB_LINELEFT... messages but it seems RichEdit's control doesn't send these messages but instead just uses SetScrollBarInfo() or something like that to move the horizontal scroll bar whenever the user wants to scroll to the vertical scrollbar to bottom.

Therefore I've tried to implement my own routine to catch SB_BOTTOM messages to avoid resetting the horizontal bar:

if Message.ScrollCode = SB_BOTTOM
yPos:= si.nPos;
si.nPos:= si.nMax;

ScrollWindowEX(handle, 0, yChar * (yPos - si.nPos),...);

just like the example in MSDN. However, while the scrollbars look like they're working properly, the actual content isn't scrolled up.

I'd like to know the reason for this and I don't think it's necessary to write my own WMPAINT function.

I don't want to use EM_LINESCROLL, SB_LINEDOWN messages either since they will give the same behaviour (i.e. resetting the horizontal scrollbar).

Does anyone know how I can fix my SB_BOTTOM routine so that the actual text is scrolled?? Thank you.

Edited by lapassion: n/a

7 Years
Discussion Span
Last Post by lapassion
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.