Thema: Delphi ListView scrollen???

Einzelnen Beitrag anzeigen

Benutzerbild von Stevie
Stevie

Registriert seit: 12. Aug 2003
Ort: Soest
4.019 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#2

Re: ListView scrollen???

  Alt 27. Sep 2004, 18:00
Entweder so:
Delphi-Quellcode:
procedure TForm1.ListView1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
  const Speed = 3;
begin
  if (ssLeft in Shift) then
  begin
    if (Y - Pos.Y > 3) then
    begin
      ListView1.Perform(WM_VSCROLL, SB_LINEDOWN, 0);
      Pos.Y := Y;
    end
    else if (Y - Pos.Y < -3) then
    begin
      ListView1.Perform(WM_VSCROLL, SB_LINEUP, 0);
      Pos.Y := Y;
    end;
  end;
end;

procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Pos.Y := Y;
end;
oder so:
Delphi-Quellcode:
procedure TForm1.ListView1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  Now.Y := Y;
end;

procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Pos.Y := Y;
  Timer1.Enabled := True;
end;

procedure TForm1.ListView1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Timer1.Enabled := False;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
  const Speed = 3;
var
  i: Integer;
begin
  for i := 1 to ((Now.Y - Pos.Y) div Speed) do
    ListView1.Perform(WM_VSCROLL, SB_LINEDOWN, 0);
  for i := -1 downto ((Now.Y - Pos.Y) div Speed) do
    ListView1.Perform(WM_VSCROLL, SB_LINEUP, 0);
end;
Stefan
“Simplicity, carried to the extreme, becomes elegance.” Jon Franklin

Delphi Sorcery - DSharp - Spring4D - TestInsight
  Mit Zitat antworten Zitat