uses
Winapi.Windows,
Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs, StdCtrls;
type
TMyListbox =
class(TListbox)
private
Fref : TCustomListbox;
procedure WMMouseWheel (
var Message: TWMMouseWheel);
message WM_Mousewheel;
procedure WMHScroll(
var Message: TWMHScroll);
message WM_HScroll;
procedure WMVScroll(
var Message: TWMVScroll);
message WM_VScroll;
public
constructor Create(AOwner: TComponent);
override;
published
property Reference: TCustomListbox
read FRef
write FRef;
end;
TForm1 =
class(TForm)
ListBox1: TListBox;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
LBox : TMyListbox;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
Listbox1.Touch.InteractiveGestures := [];
LBox := TMyListbox.Create(self);
with LBox
do begin
Parent := self;
visible := true;
top := 8;
Left := 248;
Width := 217;
Height := Listbox1.height;
Reference := Listbox1;
end;
for i := 0
to 1000
do begin
Listbox1.Items.Add(inttostr(i));
LBox.Items.Add(Inttostr(i));
end;
end;
constructor TMyListbox.Create(AOwner: TComponent);
begin
inherited;
FRef :=
nil;
end;
procedure TMyListbox.WMMouseWheel(
var Message: TWMMouseWheel);
begin
inherited;
If Assigned(FRef)
then FRef.TopIndex := Topindex;
end;
procedure TMyListbox.WMHScroll(
var Message: TWMScroll);
begin
inherited;
end;
procedure TMyListbox.WMVScroll(
var Message: TWMScroll);
begin
inherited;
if assigned(FRef)
then FRef.TopIndex := Topindex;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
LBox.Free;
end;
end.