Autor Beitrag
bruce185
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Mo 26.10.09 19:06 
Hallo,
ich möchte eine Art ProgressBar in meiner TListView zeichnen, an stelle (SubItem = 4).
Ich habe schon ein Paar Tutorials durchgemacht, aber leider ohne erfolg.

Wie setze ich richtig eine JvSpecialProgress1 Komponent in meiner TListView(SubItem = 4) hinein, ohne das Data von TListView verloren geht, da unter Data die URLs gespeichert sind?

Vielen Dank schonmal.

MfG


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Mo 26.10.2009 um 19:44
bruce185 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 283

winXP
D7 Ent
BeitragVerfasst: Di 27.10.09 19:54 
Weiss denn keiner eine lösung?

Ich habe das mal so versucht:
TJvSpecialProgress in die ListView eintragen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
var
  ListIt: TListItem;
  r:TRect;
  g: TJvSpecialProgress;
begin
  r:=ListIt.DisplayRect(drBounds);
  for i:=0 to 4 do
    r.Left:=r.Left+Form1.Liste.columns[i].Width;
  r.Right:=r.Left+Form1.Liste.columns[5].Width;
  g:=TJvSpecialProgress.Create(Form1.Liste);
  g.Parent:=Form1.Liste;
  g.BoundsRect := r;
  g.Position := 0;
  g.TextCentered := true;
  g.TextOption := toCaption;
  g.StartColor := clSkyBlue;
  g.EndColor := clSkyBlue;
  g.Caption := '0% /0.00 MB/'+MB+' MB)';
  g.Solid := true;
  ListIt.Data:=g;
end;


und hier das CustomDrawSubItem von ListView:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.listeCustomDrawSubItem(Sender: TCustomListView;
  Item: TListItem; SubItem: Integer; State: TCustomDrawState;
  var DefaultDraw: Boolean);
var 
  g:TJvSpecialProgress; 
  r:TRect;
begin 
  case SubItem of
  5:
    begin
      DefaultDraw:=false;
      g:=TJvSpecialProgress(Item.Data);
      r:=g.BoundsRect;
      r.Top:=Item.DisplayRect(drBounds).Top;
      r.Bottom:=Item.DisplayRect(drBounds).Bottom;
      g.BoundsRect:=r;
    end;
  end;
end;


beim Scrollen der ListView ist immer das letzte TJvSpecialProgress Komponent zusehen, egal an welche Position ich scrolle.

Weiss einer ne lösung?

Danke schonmal.

MfG
Critter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 328
Erhaltene Danke: 3

Windows 7
Delphi 7 Pro.
BeitragVerfasst: Mi 28.10.09 10:18 
Hi,

ich habe spontan leider keine Lösung, wie man das mit einer ListView lösen kann. Generell nutze ich für solche Späßchen immer den VirtualTree. Auch wenn die Komponente anfangs etwas schwer zu verstehen ist, erweist er sich, nach der Einarbeitung als sehr gut zu nutzen und wahnsinnig Flexiblen in der Gestaltung. Vielleicht ist das für dich ja eine Überlegung wert.

critter

_________________
Diejenigen, die grundlegende Freiheiten aufgeben, um ein wenig mehr vorrübergehende Sicherheit zu erkaufen, verdienen weder Freiheit noch Sicherheit.
(Benjamin Franklin;"The Papers of Benjamin Franklin", Vol. 6, Apr. 1, 1755, through Sep. 30, 1756)
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mi 28.10.09 14:48 
Left und Top sind immer relativ zum Parent der Komponente. Daher ist deine Berechnung in der Form falsch. Ferner solltest du mal schauen, ob du nicht mit SubItemRect oder ähnlichen Hilfsroutinen besser kommst für das BoundRect der Progressbar.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.