View Issue Details

IDProjectCategoryView StatusLast Update
0002306JEDI VCL04 Feature Requestpublic2005-05-18 06:09
ReporteranonymousAssigned Touser72 
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version3.10 
Summary0002306: Background picture for Listview
DescriptionA background picture feature would be cool in the Listview.
TagsNo tags attached.



2004-11-11 11:01


Sure would. And how is that done?


2004-11-30 01:42

viewer   ~0005763

procedure TForm1.ListView1CustomDraw(Sender: TCustomListView;
  const ARect: TRect; var DefaultDraw: Boolean);
  function GetHeaderHeight: Integer;
    Header: HWND; // header window handle
    Pl: TWindowPlacement; // header window placement
    // Get header window
    Header := SendMessage(ListView1.Handle, LVM_GETHEADER, 0, 0);
    // Get header window placement
    FillChar(Pl, SizeOf(Pl), 0);
    Pl.length := SizeOf(Pl);
    GetWindowPlacement(Header, @Pl);
    // Calculate header window height
    Result := Pl.rcNormalPosition.Bottom - Pl.rcNormalPosition.Top;

  BmpXPos, BmpYPos: Integer; // X and Y position for bitmap
  Bmp: TBitmap; // Reference to bitmap
  ItemRect: TRect; // List item bounds rectangle
  TopOffset: Integer; // Y pos where bmp drawing starts
  // Get top offset where bitmap drawing starts
  if ListView1.Items.Count > 0 then
    ListView_GetItemRect(ListView1.Handle, 0, ItemRect, LVIR_BOUNDS);
    TopOffset := ListView_GetTopIndex(ListView1.Handle) *
      (ItemRect.Bottom - ItemRect.Top);
    TopOffset := 0;
  BmpYPos := ARect.Top - TopOffset + GetHeaderHeight;
  // Draw the bitmap
  // get reference to bitmap
  Bmp := Image1.Picture.Bitmap;
  // loop until bmp is past bottom of list view
  while BmpYPos < ARect.Bottom do
    // draw bitmaps across width of display
    BmpXPos := ARect.Left;
    while BmpXPos < ARect.Right do
      ListView1.Canvas.Draw(BmpXPos, BmpYPos, Bmp);
      Inc(BmpXPos, Bmp.Width);
    // move to next row
    Inc(BmpYPos, Bmp.Height);
  // Ensure that the items are drawn transparently
  SetBkMode(ListView1.Canvas.Handle, TRANSPARENT);
  ListView_SetTextBkColor(ListView1.Handle, CLR_NONE);
  ListView_SetBKColor(ListView1.Handle, CLR_NONE);


2004-12-20 07:02

administrator   ~0005959

Thanks, but how to include that in the component itself?


2004-12-20 10:20


> Thanks, but how to include that in the component itself?
Shouldn't be much of a problem. I'll have a look


2004-12-20 14:23


I've attached a first stab that you can try out. There are some shortcomings:
- In Delphi 5, you must assign an empty handler to the OnCustomDraw event. This is due to the IsCustomDrawn method (determines whether OnCustomDraw should be called) being static, so cannot be overriden
- There is quite some flicker when ViewStyle is vsReport and you resize the header (even though I draw to an offscreen bitmap to minimize the flickering)
- There should probably be some kind of PictureOptions property (with a standard assortment of Transparent/Tile/Stretch/Proportional properties)
- With some image types, the items flicker when you select them (don't know why)

2004-12-20 14:24


JvListView.pas (40,894 bytes)


2005-02-04 05:10

administrator   ~0006404

Please provide feedback in the next 14 days, or we won't include this in the JVCL


2005-02-06 03:00

viewer   ~0006427

When using Tlistview and a background picture and you also set the OwnerData to true (for a virtual list) the content disapears when you move the mouse pointer over it. When you scroll with the scrollbar it appears again but as soon you move mouse the pointer over the content it disapears again.

BTW This bug does not appear when you set the Ownerdata to false.


2005-04-12 07:03

administrator   ~0006959

Is this now in CVS ?


2005-05-18 06:09

administrator   ~0007188

Well, I guess it is.

Issue History

Date Modified Username Field Change
2004-11-11 02:32 anonymous New Issue
2004-11-11 11:01 user72 Note Added: 0005607
2004-11-30 01:42 anonymous Note Added: 0005763
2004-12-20 07:02 obones Note Added: 0005959
2004-12-20 10:20 user72 Note Added: 0005963
2004-12-20 10:21 user72 Status new => assigned
2004-12-20 10:21 user72 Assigned To => user72
2004-12-20 14:23 user72 Note Added: 0005966
2004-12-20 14:23 user72 Status assigned => feedback
2004-12-20 14:24 user72 File Added: JvListView.pas
2005-02-04 05:10 obones Note Added: 0006404
2005-02-06 03:00 anonymous Note Added: 0006427
2005-04-12 07:03 obones Note Added: 0006959
2005-05-18 06:09 obones Status feedback => resolved
2005-05-18 06:09 obones Resolution open => fixed
2005-05-18 06:09 obones Note Added: 0007188