unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,<br>Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> ListBox1: TListBox;<br> ListBox2: TListBox;<br> ScrollBar1: TScrollBar;<br> procedure FormCreate(Sender: TObject);<br> private<br> { Private declarations }<br> FOldListBox1Proc, FOldListBox2Proc : TWndMethod;<br> procedure MyListBox1Proc(var Message:TMessage);<br> procedure MyListBox2Proc(var Message:TMessage);<br> public<br> { Public declarations }<br> end;<br><br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure TForm1.MyListBox1Proc(var Message: TMessage);<br>begin<br> if message.Msg = WM_VSCROLL then<br> begin<br> ListBox2.TopIndex := ListBox1.TopIndex;<br> end;<br> FOldListBox1Proc(message);<br>end;<br><br>procedure TForm1.MyListBox2Proc(var Message: TMessage);<br>begin<br> if message.Msg = WM_VSCROLL then<br> begin<br> ListBox1.TopIndex := ListBox2.TopIndex;<br> end;<br> FOldListBox2Proc(message);<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> FOldListBox1Proc := Listbox1.WindowProc;<br> ListBox1.WindowProc := MyListBox1Proc;<br> FOldListBox2Proc := Listbox2.WindowProc;<br> ListBox2.WindowProc := MyListBox2Proc;<br>end;