ProgressBar drag detection lazarus / 31-LCL ---------------------------------------------------------------------- Pe3s · 2022-01-09 11:36 Hello, how can I detect a drag and add events in the case of no drag and in case we detect a drag? 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.volumeProgressMouseMove(Sender: TObject; Shift: TShiftState;  X, Y: Integer);begin  if ssLeft in Shift then  begin    newPos := Round(X * Progress.MaxValue / Progress.ClientWidth);    Progress.Value := newPos;  end;end; ---------------------------------------------------------------------- balazsszekely · 2022-01-09 11:59 @ Pe3s QuoteHello, how can I detect a drag and add events in the case of no drag and in case we detect a drag?It's not clear(at least for me) what are you trying to achieve. You wish to drag the Progressbar over another control or you wish to move the progress from 30% to 60%? ---------------------------------------------------------------------- balazsszekely · 2022-01-09 14:04 @jamie Quotehe wants to use it like a TrackBar. Thanks. I don't think using a progressbar as a trackbar is a good idea, especially on windows where since vista there is an animation bug. @Pe3s Try something like this: 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.pbMouseMove(Sender: TObject; Shift: TShiftState; X,  Y: Integer);var  ProgressX: Integer;begin  if FMouseDown and FCanDrag then  begin    Screen.Cursor := crCross;    ProgressX := Round(X*100/pb.Width);    StepIt(ProgressX);    Caption := IntToStr(ProgressX) + '    ' + IntToStr(X);    Exit;  end;  ProgressX := Round(pb.Width*pb.Position/100);  FCanDrag := (X - 5 <= ProgressX) and (ProgressX < X + 5);  if FCanDrag  then    Screen.Cursor := crCross  else    Screen.Cursor := crDefault;end; procedure TForm1.pbMouseDown(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);begin  if FCanDrag then    FMouseDown := True;end; procedure TForm1.pbMouseLeave(Sender: TObject);begin  Screen.Cursor := crDefault;end; procedure TForm1.pbMouseUp(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);begin  FMouseDown := False;end; procedure TForm1.FormCreate(Sender: TObject);begin  pb.Position := 45;end; ---------------------------------------------------------------------- Pe3s · 2022-01-09 14:51 I meant something like that, if we start to drag the bar, for example, pause, if we stop dragging the bar but do not release the left mouse button, we start playing ---------------------------------------------------------------------- Pe3s · 2022-01-09 19:05 I don't understand how to do it. I have a timer  i want when I move the mouse bar 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 Timer.enabled: = False; but how do I stop moving the bar 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 Timer.enabled: = True; ---------------------------------------------------------------------- Pe3s · 2022-01-11 17:01 @Jamie Thanks for the explanation