Sorry for my bad englist.
i declared lv as TListView.
lv's viewstyle is vsReport,and i was going to place a progressbar on a
column,and that is what a downloader usually looks like.but whatever i
did
there is no progressbar on the lv(TListView).Can anybody tell me why?
Here are my codes:


Unit Unit2;

{$mode objfpc}{$H+}

Interface

Uses
  Classes, Sysutils, Fileutil, Lresources, Forms, Controls, Graphics,
Dialogs,
  ComCtrls, StdCtrls;

Type

  { Tform1 }

  Tform1 = Class(Tform)
    Button1: Tbutton;
    lv: TListView;
    Procedure Button1click(Sender: Tobject);
    Procedure Lvadvancedcustomdrawitem(Sender: Tcustomlistview;
      Item: Tlistitem; State: Tcustomdrawstate; Stage: Tcustomdrawstage;
      Var Defaultdraw: Boolean);
    Procedure Lvadvancedcustomdrawsubitem(Sender: Tcustomlistview;
      Item: Tlistitem; Subitem: Integer; State: Tcustomdrawstate;
      Stage: Tcustomdrawstage; Var Defaultdraw: Boolean);
  Private
    { Private Declarations }
  Public
    { Public Declarations }
  End; 

Var
  Form1: Tform1; 

Implementation

{ Tform1 }

Procedure Tform1.Lvadvancedcustomdrawsubitem(Sender: Tcustomlistview;
  Item: Tlistitem; Subitem: Integer; State: Tcustomdrawstate;
  Stage: Tcustomdrawstage; Var Defaultdraw: Boolean);
var
  r:TRect;
  p:TProgressBar;
Begin
  if SubItem<>1 then exit;
  r:=item.DisplayRect(drBounds);
  p:=TProgressBar.Create(Self);
  item.Data:=p;
  with p do
  begin
    Parent:=lv;
    left:=lv.left+lv.Column[0].Width;
    width:=lv.Column[1].width;
    top:=r.top;
    height:=r.bottom-r.top;
    smooth:=true;
    Max:=100;
    position:=Random(101);
  end;
End;

Procedure Tform1.Button1click(Sender: Tobject);
var
  li:TListItem;
  r:TRect;
  p:TProgressBar;
Begin
  li:=lv.Items.add;
  li.Caption:='Item '+IntToStr(lv.items.Count);
{  r:=li.DisplayRect(drBounds);
  p:=TProgressBar.Create(Self);
  li.Data:=p;
  with p do
  begin
    Parent:=lv;
    top:=0;
    left:=lv.left+lv.Column[0].Width;
    width:=lv.Column[1].width;
    top:=r.top;
    height:=r.bottom-r.top;
    smooth:=true;
    Max:=100;
    position:=Random(101);
  end;}
End;

Procedure Tform1.Lvadvancedcustomdrawitem(Sender: Tcustomlistview;
  Item: Tlistitem; State: Tcustomdrawstate; Stage: Tcustomdrawstage;
  Var Defaultdraw: Boolean);
var
  r:TRect;
  p:TProgressBar;
Begin
  r:=item.DisplayRect(drBounds);
  p:=TProgressBar.Create(Self);
  item.Data:=p;
  with p do
  begin
    Parent:=lv;
    left:=lv.left+lv.Column[0].Width;
    width:=lv.Column[1].width;
    top:=r.top;
    height:=r.bottom-r.top;
    smooth:=true;
    Max:=100;
    position:=Random(101);
  end;
End;

Initialization
  {$I unit2.lrs}

End.    

Regards,
Yan Chengyuan


_______________________________________________
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to