Forum > LCL

ProgressBar drag detection

(1/2) > >>

Pe3s:
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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;  

GetMem:
@ Pe3s

--- Quote ---Hello, how can I detect a drag and add events in the case of no drag and in case we detect a drag?
--- End quote ---
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%?

GetMem:
@jamie


--- Quote ---he wants to use it like a TrackBar.

--- End quote ---
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  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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:
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:
I don't understand how to do it.
I have a timer
 i want when I move the mouse bar
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Timer.enabled: = False; but how do I stop moving the bar
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Timer.enabled: = True;

Navigation

[0] Message Index

[#] Next page

Go to full version