Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-04

How to draw a progressbar under a column of a listview?

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

闫程远

hi,all!
i just want to know how to draw a progressbar under a specified column of a listview.
first i wanted to draw a progressbar.i know there is a method of a TListItem called "DisplayRect",but whatever i do,the rect it returns is (0,0,0,0) and whatever i wrote for the drawsubitem/drawitem method it just doesn't work.
then i tried to put a Tprogressbar under a column,and it failed again. can anyone help me?

regard,
Yan Chengyuan

I'm sure that I will win. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20090411/6e63756c/attachment.html

Reply by email

Graeme Geldenhuys
to 闫程远

2009/4/11 ??? :

first i wanted to draw a progressbar.i know there is a method of a TListItem called "DisplayRect",but whatever i do,the rect it returns is (0,0,0,0)

As far as I can see you have found a bug. Please report this in Mantis.

I have tried the following code and the DisplaySubItemRect() is also always (0,0,0,0). The other thing is that I use Sender (TCustomListView type) to retrieve the canvas. If the code below runs, the whole Form is painted Green, whereas at least it should only have been inside the ListView.

I use Lazarus (latest trunk revision) with GTK2 widgetset. Can you try to reproduce this and give feedback?

Steps to reproduce:
-----------------------------
* New LCL application
* Drop TListView on form
* Create 3 new items.
* Create 1 new subitem for each item.
* Add the event handler below
* Run from command line (so writeln() statements work)

===================================
procedure TForm1.ListView1CustomDrawSubItem(Sender: TCustomListView;
Item: TListItem;
  SubItem: Integer; State: TCustomDrawState; var DefaultDraw: Boolean);
var
  rect: TRect;
begin
  writeln('CustomDrawSubItem');
  if Item.Caption = 'Item1' then
  begin
//    if cdsDefault in State then
    begin
//      DefaultDraw := False;
      Rect := Item.DisplayRectSubItem(SubItem, drBounds);
      writeln('r.right = ', rect.Right);
      Brush.Color := clGreen;
      Rect.Right := Trunc(Rect.Right * 0.75); // 75%
      Sender.Canvas.FillRect(Rect);
    end;
  end;
end;
===================================
Show quoted text 17 lines
and whatever i wrote for the drawsubitem/drawitem method it just doesn't work. then i tried to put a Tprogressbar under a column,and it failed again. can anyone help me? regard, Yan Chengyuan -- I'm sure that I will win. _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Regards, - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://opensoft.homeip.net/fpgui/

Reply by email

lonelycorn
to Graeme Geldenhuys

i was busy these days doing some homework,so sorry to be late. i've done as you told and in fact there is no reply from the code.i think this means that lazarus didn't even execute the codes. Here are the results i got:
"
Gtk-WARNING **: Failed to load module "libcanberra-gtk-module.so": libcanberra-gtk-module.so: cannot open shared object file: ?????? ??
[WARNING] Out of OEM specific VK codes, changing to unassigned [WARNING] Out of unassigned VK codes, assigning $FF "
the Chinese means that "there is no such file or directory"

? 2009-04-11?? 08:43 +0200?Graeme Geldenhuys???

Show quoted text 64 lines
2009/4/11 ??? : > first i wanted to draw a progressbar.i know there is a method of a TListItem > called "DisplayRect",but whatever i do,the rect it returns is (0,0,0,0) As far as I can see you have found a bug. Please report this in Mantis. I have tried the following code and the DisplaySubItemRect() is also always (0,0,0,0). The other thing is that I use Sender (TCustomListView type) to retrieve the canvas. If the code below runs, the whole Form is painted Green, whereas at least it should only have been inside the ListView. I use Lazarus (latest trunk revision) with GTK2 widgetset. Can you try to reproduce this and give feedback? Steps to reproduce: ----------------------------- * New LCL application * Drop TListView on form * Create 3 new items. * Create 1 new subitem for each item. * Add the event handler below * Run from command line (so writeln() statements work) =================================== procedure TForm1.ListView1CustomDrawSubItem(Sender: TCustomListView; Item: TListItem; SubItem: Integer; State: TCustomDrawState; var DefaultDraw: Boolean); var rect: TRect; begin writeln('CustomDrawSubItem'); if Item.Caption = 'Item1' then begin // if cdsDefault in State then begin // DefaultDraw := False; Rect := Item.DisplayRectSubItem(SubItem, drBounds); writeln('r.right = ', rect.Right); Brush.Color := clGreen; Rect.Right := Trunc(Rect.Right * 0.75); // 75% Sender.Canvas.FillRect(Rect); end; end; end; =================================== > and whatever i wrote for the drawsubitem/drawitem method it just doesn't > work. > then i tried to put a Tprogressbar under a column,and it failed again. > can anyone help me? > > regard, > Yan Chengyuan > > -- > I'm sure that I will win. > > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > >

Reply by email

lonelycorn
to Graeme Geldenhuys: 2009/4/11 ??? : As far as I can see you have found a bug. Please report this in Mantis. I…

i was busy these days doing some homework,so sorry to be late. i've done as you told and in fact there is no reply from the code.i think this means that lazarus didn't even execute the codes. Here are the results i got:
"
Gtk-WARNING **: Failed to load module "libcanberra-gtk-module.so": libcanberra-gtk-module.so: cannot open shared object file: ?????? ??
[WARNING] Out of OEM specific VK codes, changing to unassigned [WARNING] Out of unassigned VK codes, assigning $FF "
the Chinese means that "there is no such file or directory"

i'm using lazarus 0.9.26.4 from a ubuntu (jaunty--beta) third-party source .fpc version is 2.2.2-8
and i have to say that since lazarus 0.9.26 the synedit looks awful after re-compiled with GTK2. i mean that the letters weren't displayed correctly-there were some missing;and when highlighted,the letters that were once missing appeared again!.that is the same with lazarus 0.9.26.2 and 0.9.26.4

? 2009-04-11?? 08:43 +0200?Graeme Geldenhuys???

Show quoted text 64 lines
2009/4/11 ??? : > first i wanted to draw a progressbar.i know there is a method of a TListItem > called "DisplayRect",but whatever i do,the rect it returns is (0,0,0,0) As far as I can see you have found a bug. Please report this in Mantis. I have tried the following code and the DisplaySubItemRect() is also always (0,0,0,0). The other thing is that I use Sender (TCustomListView type) to retrieve the canvas. If the code below runs, the whole Form is painted Green, whereas at least it should only have been inside the ListView. I use Lazarus (latest trunk revision) with GTK2 widgetset. Can you try to reproduce this and give feedback? Steps to reproduce: ----------------------------- * New LCL application * Drop TListView on form * Create 3 new items. * Create 1 new subitem for each item. * Add the event handler below * Run from command line (so writeln() statements work) =================================== procedure TForm1.ListView1CustomDrawSubItem(Sender: TCustomListView; Item: TListItem; SubItem: Integer; State: TCustomDrawState; var DefaultDraw: Boolean); var rect: TRect; begin writeln('CustomDrawSubItem'); if Item.Caption = 'Item1' then begin // if cdsDefault in State then begin // DefaultDraw := False; Rect := Item.DisplayRectSubItem(SubItem, drBounds); writeln('r.right = ', rect.Right); Brush.Color := clGreen; Rect.Right := Trunc(Rect.Right * 0.75); // 75% Sender.Canvas.FillRect(Rect); end; end; end; =================================== > and whatever i wrote for the drawsubitem/drawitem method it just doesn't > work. > then i tried to put a Tprogressbar under a column,and it failed again. > can anyone help me? > > regard, > Yan Chengyuan > > -- > I'm sure that I will win. > > _______________________________________________ > Lazarus mailing list > > http://www.lazarus.freepascal.org/mailman/listinfo/lazarus > >

Reply by email