I first had a TMemo and when I grabbed the scrollbar thumb, the Memo content scrolled Line-by-line, meaning not smooth pixel-by-pixel.
Then I switched over to use a TRichEdit control instead. But now it scrolls smooth, pixel-by-pixel.
Is there a way to configure the TRichEdit control to behave more like the TMemo control, scrolling a full line at a time?
I do realise that a TRichEdit can have different line height depending on selected style. But this shouldn't be a problem if top line always was aligned (not displayed half).
If there is no simple way, I can just adjust the position in the WM_VSCROLL message...
Okay so I figure it out.
My solution was to read the scrollbar position and calculate the line number from it. Then calculate the delta number of lines to scroll from the current line position.
I captured the
WM_MOUSEWHEEL
andWM_VSCROLL
and translated them intoEM_LINESCROLL
messages instead.PrevWndProc()
is the originalWindowProc()
function andGetLineNumber()
returns the top line index of the RichEdit control (EM_GETFIRSTVISIBLELINE
).I hope this is helpful if someone else has the same problem.