[SOLVED] TPanel bar MouseWheel step lazarus / 31-LCL ---------------------------------------------------------------------- Pe3s · 2023-11-23 16:40 Hello, how can I program the OnMouseWheel event with increments of 5? Regards Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, LCLIntf, Types, Math; type   { TForm1 }   TForm1 = class(TForm)    Panel1: TPanel;    Panel2: TPanel;    procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer    );    procedure Panel1Paint(Sender: TObject);  private   public   end; var  Form1: TForm1;  BarPos: Integer = 100;  implementation {$R *.lfm} { TForm1 } procedure TForm1.Panel1Paint(Sender: TObject);var  R: TRect;begin  with Panel1, Canvas dobegin  R := Rect(0, 0, Panel1.Width * BarPos div 100, Panel1.Height);  Brush.Color := RGB(250, 208, 44);  FillRect(R);end;end; procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);begin  if (ssLeft in Shift) then   begin     BarPos := EnsureRange(X * 100 div Panel1.Width, 0, 100);     if(BarPos mod 5) = 0 then      begin        Panel1.Invalidate;        Panel2.Caption := IntToStr(BarPos);      end;   end;end; end. ---------------------------------------------------------------------- Handoko · 2023-11-23 17:23 Done. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, ExtCtrls, LCLIntf; type   { TForm1 }   TForm1 = class(TForm)    Panel1: TPanel;    Panel2: TPanel;    procedure Panel1MouseWheel(Sender: TObject; Shift: TShiftState;      WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);    procedure Panel1Paint(Sender: TObject);  end; var  Form1: TForm1;  BarPos: Integer = 100;  implementation {$R *.lfm} { TForm1 } procedure TForm1.Panel1Paint(Sender: TObject);var  R: TRect;begin  with Panel1, Canvas do  begin    R := Rect(0, 0, Panel1.Width * BarPos div 100, Panel1.Height);    Brush.Color := RGB(250, 208, 44);    FillRect(R);  end;end; procedure TForm1.Panel1MouseWheel(Sender: TObject; Shift: TShiftState;  WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);const  Step = 5;begin  case WheelDelta < 0 of    True:  BarPos := BarPos - Step;    False: BarPos := BarPos + Step;  end;  if BarPos < 0   then BarPos := 0;  if BarPos > 100 then BarPos := 100;  Panel1.Invalidate;  Panel2.Caption := IntToStr(BarPos);end; end. Tested on Ubuntu Mate only, but I think it should work too on Windows. ---------------------------------------------------------------------- Pe3s · 2023-11-23 17:34 @Handoko, I noticed that if we move the mouse bar and then use the mouse wheel, the values ​​do not match. It is possible to make the values ​​the same every 5. Why does this happen? Regards ---------------------------------------------------------------------- Handoko · 2023-11-23 17:42 Add this MouseMove event: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,  Y: Integer);begin  if not(ssLeft in Shift) then Exit;  BarPos := EnsureRange(X * 100 div Panel1.Width, 0, 100);  BarPos := BarPos - (BarPos mod 5);  Panel1.Invalidate;  Panel2.Caption := IntToStr(BarPos);end; ---------------------------------------------------------------------- Pe3s · 2023-11-23 17:59 @Handoko, Thank you for your help Regards