Recent

Author Topic: [Solved] TRichMemo - Adjust Scrolling Speed  (Read 3158 times)

OLLI_S

  • Full Member
  • ***
  • Posts: 119
[Solved] TRichMemo - Adjust Scrolling Speed
« on: November 17, 2018, 04:14:16 pm »
Hello,

I am using Lazarus 1.8.4 in Windows 10 Professional x64.

I have a form where I used a TMemo control to display some text.
Now I switched to a TRichMemo control, because I needed some text in red color.
But I recognized a scrolling issue in the TRichMemo.

When I scroll one step using the mouse wheel in the TMemo control, then a full line of text is scrolled.
When I scroll in the TRichMemo then only a part of the line is scrolled (I have to scroll 5-6 steps to scroll one complete line).

Both controls have the same font and font size.
And both have the same text (content).

So how can I increase the scrolling speed of the TRichMemo?
Thank you!

Best regards

OLLI
« Last Edit: February 10, 2019, 09:45:38 pm by OLLI_S »

OLLI_S

  • Full Member
  • ***
  • Posts: 119
Re: Adjust Scrolling Speed in TRichMemo
« Reply #1 on: February 10, 2019, 02:35:03 pm »
Hello,

some of my users complained about the scrolling speed of my two TRichMemo controls.
Is there a way to change the scrolling behavior?
Thank you for your help.

Best regards

OLLI

sstvmaster

  • Sr. Member
  • ****
  • Posts: 299
Re: TRichMemo - Adjust Scrolling Speed
« Reply #2 on: February 10, 2019, 06:18:17 pm »
Hi OLLI,

for scrolling you can use this:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.RichMemo1MouseWheel(Sender: TObject; Shift: TShiftState;
  2.   WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
  3. begin
  4.   case WheelDelta of
  5.     120: begin
  6.       SendMessage(RichMemo1.Handle, EM_LINESCROLL,0,-1);
  7.     end;
  8.     -120: begin
  9.       SendMessage(RichMemo1.Handle, EM_LINESCROLL,0,1);
  10.     end;
  11.   end;
  12. end;
« Last Edit: February 10, 2019, 06:22:01 pm by sstvmaster »
greetings Maik

Windows 10,
- Lazarus 2.2.6 (stable) + fpc 3.2.2 (stable)
- Lazarus 2.2.7 (fixes) + fpc 3.3.1 (main/trunk)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: TRichMemo - Adjust Scrolling Speed
« Reply #3 on: February 10, 2019, 06:31:22 pm »
I have a form where I used a TMemo control to display some text.
Now I switched to a TRichMemo control, because I needed some text in red color.
But I recognized a scrolling issue in the TRichMemo.
It's not an issue, it's intentional.
Since RichMemo can have different font sizes per line, scrolling by lines makes little to not sense.
(You might want to add wordwrapping problems).

Thus RichMemo always scrolls by pixels (on all platforms)

OLLI_S

  • Full Member
  • ***
  • Posts: 119
Re: TRichMemo - Adjust Scrolling Speed
« Reply #4 on: February 10, 2019, 08:23:03 pm »
Hello,

if the TRichMemo is scrolling by pixels, can I somehow adjust the number of pixels that are scrolled?
My problem is that I show here a Change-Log in RTF text and if users want to read the Change-Log they have to scroll a lot.

Best regards

OLLI

sstvmaster

  • Sr. Member
  • ****
  • Posts: 299
Re: TRichMemo - Adjust Scrolling Speed
« Reply #5 on: February 10, 2019, 09:14:17 pm »
@OLLI
Did you read my post?
greetings Maik

Windows 10,
- Lazarus 2.2.6 (stable) + fpc 3.2.2 (stable)
- Lazarus 2.2.7 (fixes) + fpc 3.3.1 (main/trunk)

OLLI_S

  • Full Member
  • ***
  • Posts: 119
Re: TRichMemo - Adjust Scrolling Speed
« Reply #6 on: February 10, 2019, 09:45:05 pm »
@OLLI
Did you read my post?

 :-[
When I posted my answer I must have overseen it (I really can not explain why).
But thank you, your code is working perfectly.

I have two TRichMemo controls, so I made a common procedure that is called by both TRichMemo controls.
I just had to cast the sender so it is working:

Code: Pascal  [Select][+][-]
  1. procedure TfrmMainForm.TRichMemoMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
  2. begin
  3.   case WheelDelta of
  4.     120: begin
  5.       SendMessage(TRichMemo(Sender).Handle, EM_LINESCROLL,0,-1);
  6.     end;
  7.     -120: begin
  8.       SendMessage(TRichMemo(Sender).Handle, EM_LINESCROLL,0,1);
  9.     end;
  10.   end;
  11. end;  

Thank you again sstvmaster !

Best regards

OLLI

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: [Solved] TRichMemo - Adjust Scrolling Speed
« Reply #7 on: February 10, 2019, 10:40:54 pm »
Now if you want to get fancy with that, you can check the SHIFT value and have it do page jumps or
smooth scroll when you want them by holding a key down on the board like the shift, control alt etc..
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018