Re: [Lazarus] Unable to use method AdvancedCustomDrawItem and, AdvancedCustomDrawSubItem

2009-03-17 Thread YanChengyuan
but i made it with lazarus under windows.
and i could not use customdraw method to draw anything.

 
  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.
 It is not possible to place a TProgressbar in a listview. (item.data 
 does nothing, it's for user defined data independent of the LCL)
 
 What you have have to do is to draw a own bar, e.g. with two or more 
 rectangles (see canvas)
 
 
 Benito
 ___
 Lazarus mailing list
 Lazarus@lazarus.freepascal.org
 http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Unable to use method AdvancedCustomDrawItem and AdvancedCustomDrawSubItem

2009-03-16 Thread YanChengyuan
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 SubItem1 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


Re: [Lazarus] Unable to use method AdvancedCustomDrawItem and, AdvancedCustomDrawSubItem

2009-03-16 Thread Benito van der Zander

 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.
It is not possible to place a TProgressbar in a listview. (item.data 
does nothing, it's for user defined data independent of the LCL)

What you have have to do is to draw a own bar, e.g. with two or more 
rectangles (see canvas)


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