Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0002306 [JEDI VCL] 04 Feature Request feature N/A 2004-11-11 02:32 2005-05-18 06:09
Reporter anonymous View Status public  
Assigned To user72
Priority normal Resolution fixed  
Status resolved   Product Version
Summary 0002306: Background picture for Listview
Description A background picture feature would be cool in the Listview.
Additional Information
Tags No tags attached.
Attached Files ? file icon JvListView.pas [^] (40,894 bytes) 2004-12-20 14:24

- Relationships

-  Notes
(0005607)
user72
2004-11-11 11:01

Sure would. And how is that done?
(0005763)
anonymous (viewer)
2004-11-30 01:42

procedure TForm1.ListView1CustomDraw(Sender: TCustomListView;
  const ARect: TRect; var DefaultDraw: Boolean);
  function GetHeaderHeight: Integer;
  var
    Header: HWND; // header window handle
    Pl: TWindowPlacement; // header window placement
  begin
    // 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;
  end;

var
  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
begin
  // Get top offset where bitmap drawing starts
  if ListView1.Items.Count > 0 then
  begin
    ListView_GetItemRect(ListView1.Handle, 0, ItemRect, LVIR_BOUNDS);
    TopOffset := ListView_GetTopIndex(ListView1.Handle) *
      (ItemRect.Bottom - ItemRect.Top);
  end
  else
    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
  begin
    // draw bitmaps across width of display
    BmpXPos := ARect.Left;
    while BmpXPos < ARect.Right do
    begin
      ListView1.Canvas.Draw(BmpXPos, BmpYPos, Bmp);
      Inc(BmpXPos, Bmp.Width);
    end;
    // move to next row
    Inc(BmpYPos, Bmp.Height);
  end;
  // Ensure that the items are drawn transparently
  SetBkMode(ListView1.Canvas.Handle, TRANSPARENT);
  ListView_SetTextBkColor(ListView1.Handle, CLR_NONE);
  ListView_SetBKColor(ListView1.Handle, CLR_NONE);
end;
(0005959)
obones (administrator)
2004-12-20 07:02

Thanks, but how to include that in the component itself?
(0005963)
user72
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
(0005966)
user72
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)
(0006404)
obones (administrator)
2005-02-04 05:10

Please provide feedback in the next 14 days, or we won't include this in the JVCL
(0006427)
anonymous (viewer)
2005-02-06 03:00

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.
(0006959)
obones (administrator)
2005-04-12 07:03

Is this now in CVS ?
(0007188)
obones (administrator)
2005-05-18 06:09

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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker