On 28/05/2014 00:46, Etienne Leblois wrote:
 how to manage that scrolling or arrowing up in one memo will also
scroll up the other one ?

The following Windows example shows how to synchronise scrolling between two memos (Memo1, Memo2) using scrollbar movement. Responding to memo caret movement in addition would require more code based on the same message-interception ideas.

//== code ==

unit mainScrollMemo;

{$mode objfpc}{$H+}

interface

uses
  Classes, Forms, Controls, LMessages, StdCtrls;

type

  TForm1 = class(TForm)
    Memo1: TMemo;
    Memo2: TMemo;
    procedure FormCreate(Sender: TObject);
  private
    FOrgMemoWndProc: TWndMethod;
    procedure MemoWndMethod(var theMessage: TLMessage);
  end;

var
  Form1: TForm1;

implementation

uses windows;

{$R *.lfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  FOrgMemoWndProc:=Memo1.WindowProc;
  Memo1.WindowProc:=@MemoWndMethod;
  memo1.Lines.LoadFromFile('..\..\mainscrollmemo.pp');
  memo2.Lines.LoadFromFile('..\..\mainscrollmemo.pp');
end;

procedure TForm1.MemoWndMethod(var theMessage: TLMessage);
begin
  FOrgMemoWndProc(theMessage);

  if theMessage.msg=LM_VSCROLL then
SendMessage(Memo2.Handle, WM_VSCROLL, theMessage.wParam , theMessage.lParam);

  if theMessage.wParamlo=SB_THUMBTRACK then
    SetScrollPos(Memo2.Handle, SB_VERT, theMessage.wParamhi, True);
end;

end.

//== code end ==

You should be able to adapt this to your needs.

Howard



--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to