Board index » delphi » Scrolling in RichEdit

Scrolling in RichEdit

Does anybody know how to detect whether or not a RichEdit component is being
scrolled (vertically)?  Sort of like an OnScroll event or something?  Thanks
in advance.
 

Re:Scrolling in RichEdit


Not sure if this will work but how about just peeking into the message
loop to see if your application recieved a WM_VSCROLL message..

Something like:

private
    { Private declarations }

protected
   procedure WMVScroll(var Message: TMessage); message WM_VSCROLL;

*******************************************************************************

procedure TMainForm.WMVScroll(var Message: TMessage);
begin
 ShowMessage('Recieved WM_VSCROLL message!');
 Message.Result := 0;
end;

Not sure if this will work because you might need to inherit a new
control from TRichEdit and use this same type of code to detect when IT
ius recieving the message.

HTH

RKr

Quote
BS wrote:

> Does anybody know how to detect whether or not a RichEdit component is being
> scrolled (vertically)?  Sort of like an OnScroll event or something?  Thanks
> in advance.

Re:Scrolling in RichEdit


Quote
In article <378E9E43.D2595...@home.com>, Reid Roman <rkro...@home.com> writes:
>Not sure if this will work because you might need to inherit a new
>control from TRichEdit and use this same type of code to detect when IT
>ius recieving the message.

That's correct Reid, and you should also call "inherited" after any action you
do. Also for WM_VSCROLL you do not need to set the result.

uses
  ComCtrls;

type
  TVSRichEdit = class(TRichEdit)
    procedure WMVScroll(var Msg : TMessage); message WM_VSCROLL;
  end;

var
  MyRichEdit : TVSRichEdit;

procedure TForm1.FormCreate(Sender: TObject);
begin
  MyRichEdit := TVSRichEdit.Create(Self);
  with MyRichEdit do begin
     Parent := Self;  // or whatever
     SetBounds(25, 25, 150, 250); // size & position control
     ScrollBars := ssBoth;
     WordWrap := false;  // to get horizontal scrollbar
     Lines.LoadFromFile('C:\AutoExec.bak'); // something to display for
scrolling test
  end;
end;

procedure TVSRichEDit.WMVScroll(var Msg : TMessage);
begin
  Form1.Panel1.Color := clRed;  // just an indicator of action - turned off by
a timer
  inherited;    // so that normal scroll action is done
end;

Alan Lloyd
alangll...@aol.com

Other Threads