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
begin
GetScrollInfo();..
yPos:= si.nPos;
si.nPos:= si.nMax;
...
SetScrollInfo();..

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

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.

Help!!!! Anyone???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.