[DUG] Drawing images in TListView sub items

Robert martin rob at wildsoft.co.nz
Fri Sep 8 12:17:26 NZST 2006


Hi

I am trying to draw images into a TListView (vsReport) on the 
ownerDrawSubItem event.  However I need to get the TRect of the sub item 
to draw into.  I have found people use

*ListView_GetSubItemRect*(

However this Win API ?  Is not defined in Delphi 6.  Could someone with 
a newer Delphi version cut and paste the definition for me (I want to 
get it right). 

Is this the right way of doing it?

I am wanting to do something like...


procedure TMainForm.ResultListViewCustomDrawSubItem(
  Sender: TCustomListView; Item: TListItem; SubItem: Integer;
  State: TCustomDrawState; var DefaultDraw: Boolean);
var
    SubItemRect     : TRect;
begin
    if (Item.SubItems[SubItem]  = 'T') then begin
        ListView_GetSubItemRect(Sender.Handle, Item.Index, SubItem, 0, 
@SubItemRect);

        ResultListView.Canvas.StretchDraw(SubItemRect, 
TickImage.Picture.Graphic);
    end
    else if (Item.SubItems[SubItem] = 'F') then begin
        //Stubbed
    end
    else if (Item.SubItems[SubItem] = 'O') then begin
        //Stubbed
    end;



-- 
Rob Martin
Software Engineer

phone +64 03 377 0495
fax   +64 03 377 0496
web www.chreos.com

Wild Software Ltd



More information about the Delphi mailing list