0

I want a multiline CEdit control to scroll itself downside slowly like a rolling subtitle.

So far, I use CEdit::LineScroll() in OnTimer() event. It can do a full line roll with is not as smooth as I expected. I try to replace LineScroll() by ScrollWindow() so that I can scroll the text by pixels however the ScrollWindow() function don't draw the new text lines which should be scrolled into the control.

Anyone have any idea on how to achieve this?

In case I did not describe the issue clear. I add these gifs: What LineScroll() do (and I just need it smoother):

LineScrool

And this is what ScrollWindow() do (the following text is cut):

ScrollWindow

Here is the code of ScrollWindow():

CRect clientRect;
m_editAns.GetClientRect(&clientRect);
m_editAns.ScrollWindow(0, -10, NULL, &clientRect);
m_editAns.UpdateWindow();
ValidateRect(&clientRect);

*PS: The project uses the CEdit control else where so I can't replace it by another control, though inheritance is acceptable.

SuperLucky
  • 595
  • 5
  • 15

1 Answers1

0

According to CWnd::ScrollWindow,

To repaint the uncovered area at the same time the scrolling is done, call the UpdateWindow member function immediately after calling ScrollWindow.

Edward Clements
  • 5,040
  • 2
  • 21
  • 27
  • Here is my code in OnTimer(): `m_editCtrl.ScrollWindow(0,-10,NULL,&clientRect); m_editCtrl.UpdateWindow();` Same problem, new lines not showing. – SuperLucky Sep 26 '13 at 05:52
  • Could you try without using the clipping rectangle `m_editCtrl.ScrollWindow(0, -10, NULL, NULL)`? – Edward Clements Sep 26 '13 at 06:45
  • You may need to invalidate the uncovered area first with InvalidateRect if UpdateWindow doesn't cause a redraw. – xMRi Sep 27 '13 at 07:06
  • Only one thing I can think of -- are you handling WM_PAINT messages in your code? Could it be that the edit redraw is somehow getting skipped? – Edward Clements Sep 30 '13 at 09:25