View Issue Details

IDProjectCategoryView StatusLast Update
0009255LazarusWidgetsetpublic2013-09-03 12:07
ReporterMario Bonati Assigned ToVincent Snijders  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
PlatformWin32OSWinXP 
Product Version0.9.23 (SVN) 
Fixed in Version0.9.27 (SVN) 
Summary0009255: Cant' color columns in ListView
Descriptioni use this code in Delphi to colorate with different colors columns of a ListView, but with Lazarus they does nothing:


procedure TForm1.SetLVColumnColour(ColIdx: Integer);
  // Sets the list view brush colour for the column
const
  // The colours for each list view column
  cRainbow: array[0..3] of TColor = (
    $FFCCCC, $CCFFCC, $CCCCFF, $CCFFFF
  );
begin
  ListView1.Canvas.Brush.Color := cRainBow[ColIdx];
end;

procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState;
  var DefaultDraw: Boolean);
  // Draw the "Caption" column
begin
  // Set the colour for column 0
  SetLVColumnColour(0);
end;

procedure TForm1.ListView1CustomDrawSubItem(Sender: TCustomListView;
  Item: TListItem; SubItem: Integer; State: TCustomDrawState;
  var DefaultDraw: Boolean);
  // Draw the sub item columns
begin
  // Check if SubItem is 0 and exit (Delphi 4 calls this event
  // with SubItem = 0, while Delphi 7 starts with SubItem = 1
  if SubItem = 0 then Exit;
  // We set the background colour to the colour required for
  // the column per the SubItem parameter
  SetLVColumnColour(SubItem);
end;



Same problem whit these that i use for colorate lines:

procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
  Item: TListItem; State: TCustomDrawState;
  var DefaultDraw: Boolean);
const
  cStripe = $CCFFCC; // colour of alternate list items
begin
  if Odd(Item.Index) then
    // odd list items have green background
    ListView1.Canvas.Brush.Color := cStripe
  else
    // even list items have window colour background
    ListView1.Canvas.Brush.Color := clWindow;
end;
TagsNo tags attached.
Fixed in Revision20273
LazTarget1.4
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0007059 resolvedZeljan Rikalo Lazarus TListView: OnCustomDraw event 
parent of 0013847 closedPaul Ishenin Patches Fix for owner drawn TListView on Windows 
related to 0015856 closedVincent Snijders Lazarus TListView -> Canvas.Brush.Color -> not working (OnCustomDrawItem/SubItem) 

Activities

Vincent Snijders

2009-05-28 09:24

manager   ~0028095

Please test and close if OK.

Issue History

Date Modified Username Field Change
2007-07-13 07:12 Mario Bonati New Issue
2007-07-13 07:12 Mario Bonati Widgetset => Win32
2007-07-13 09:02 Vincent Snijders LazTarget => post 1.2
2007-07-13 09:02 Vincent Snijders Status new => acknowledged
2007-07-13 09:03 Vincent Snijders Category - => Widgetset
2007-09-21 05:34 Paul Ishenin Relationship added related to 0007059
2009-05-28 06:39 Vincent Snijders Relationship added parent of 0013847
2009-05-28 09:24 Vincent Snijders Fixed in Revision => 20273
2009-05-28 09:24 Vincent Snijders Status acknowledged => resolved
2009-05-28 09:24 Vincent Snijders Fixed in Version => 0.9.27 (SVN)
2009-05-28 09:24 Vincent Snijders Resolution open => fixed
2009-05-28 09:24 Vincent Snijders Assigned To => Vincent Snijders
2009-05-28 09:24 Vincent Snijders Note Added: 0028095
2009-05-28 16:05 Mario Bonati Status resolved => closed
2010-11-02 12:15 Vincent Snijders Relationship added related to 0015856
2013-09-03 12:07 Martin Friebe LazTarget post 1.2 => 1.4