1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| procedure TNomDeLaForm_e.FormMouseWheel(Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
var
i: integer;
PosHautGauche: TPoint;
PosBasDroite: TPoint;
begin
for i := 0 to TForm(Sender).ComponentCount - 1 do
begin
try
if TForm(Sender).Components[i] is TScrollBox then
begin
if (TForm(Sender).Components[i] as Tscrollbox).CanFocus then
begin
PosHautGauche.X := (TForm(Sender).Components[i] as TScrollBox).Left;
PosHautGauche.Y := (TForm(Sender).Components[i] as TScrollBox).Top;
PosBasDroite.X := (TForm(Sender).Components[i] as TScrollBox).Left
+ (TForm(Sender).Components[i] as TScrollBox).Width;
PosBasDroite.Y := (TForm(Sender).Components[i] as TScrollBox).Top
+ (TForm(Sender).Components[i] as TScrollBox).Height;
PosHautGauche := TForm(Sender).ScreenToClient((TForm(Sender).Components[i] as TScrollBox).ClientToScreen(PosHautGauche));
PosHautGauche.X := PosHautGauche.X + TForm(Sender).Left;
PosHautGauche.Y := PosHautGauche.Y + TForm(Sender).Top + TForm(Sender).Height - TForm(Sender).ClientHeight;
PosBasDroite := TForm(Sender).ScreenToClient((TForm(Sender).Components[i] as TScrollBox).ClientToScreen(PosBasDroite));
PosBasDroite.X := PosBasDroite.X + TForm(Sender).Left;
PosBasDroite.Y := PosBasDroite.Y + TForm(Sender).Top + TForm(Sender).Height - TForm(Sender).ClientHeight;
if (MousePos.X > PosHautGauche.X) and (MousePos.Y > PosHautGauche.Y)
and (MousePos.X < PosBasDroite.X) and (MousePos.Y < PosBasDroite.Y)
then
(TForm(Sender).Components[i] as TScrollBox).VertScrollBar.Position := (TForm(Sender).Components[i] as TScrollBox).VertScrollBar.Position - WheelDelta;
end;
end;
except
end;
end;
end; |