[DUG] Drawing images in TListView sub items

Robert martin rob at wildsoft.co.nz
Fri Sep 8 12:45:21 NZST 2006


Hi

I new most of that stuff, I am actually looking at the delphi definition 
of it..

I have

function ListView_GetSubItemRect(hwndLV : HWND; iItem : Integer; 
iSubItem : Integer; Code : Integer; lpRect : Pointer): Bool; stdcall;

But it goes bang when I start my app.   I always struggle with these 
things :-(


Rob Martin
Software Engineer

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

Wild Software Ltd



John Bird wrote:
> If this is what you mean here is the excerpt from the D2006 help...
>
> ListView_GetSubItemRect Macro
>
> ----------------------------------------------------------------------------
> ----
>
> Retrieves information about the rectangle that surrounds a subitem in a
> list-view control. You can use this macro (recommended) or send the
> LVM_GETSUBITEMRECT message explicitly. This macro is intended to be used
> only on list-view controls that use the LVS_REPORT style. 
>
> Syntax
>
> BOOL ListView_GetSubItemRect(
>     HWND hwndLV,
>     int iItem,
>     int iSubItem,
>     int code,
>     LPRECT lpRect
> );
>
> Parameters
>
> hwndLV
> Handle to a list-view control. 
> iItem
> Index of the subitem's parent item. 
> iSubItem
> The one-based index of the subitem. 
> code
> Portion of the list-view subitem for which to retrieve the bounding
> rectangle information. This value can be one of the following: 
> LVIR_BOUNDS
> Returns the bounding rectangle of the entire item, including the icon and
> label.
> LVIR_ICON
> Returns the bounding rectangle of the icon or small icon.
> LVIR_LABEL
> Returns the bounding rectangle of the entire item, including the icon and
> label. This is identical to LVIR_BOUNDS.
> lpRect
> Pointer to a RECT structure that receives the subitem bounding rectangle
> information. 
> Return Value
>
> Returns nonzero if successful, or zero otherwise.
>
> Macro Information
>
> Minimum DLL Version comctl32.dll version 4.70 or later 
> Header commctrl.h 
> Minimum operating systems Windows 2000, Windows NT 4.0 with Internet
> Explorer 3.0, Windows 98, Windows 95 with Internet Explorer 3.0 
>
>
> John
>
> -----Original Message-----
> From: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz] On
> Behalf Of Robert martin
> Sent: Friday, 8 September 2006 12:17 p.m.
> To: NZ Borland Developers Group - Delphi List
> Subject: [DUG] Drawing images in TListView sub items
>
>
> 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;
>
>
>
>   


More information about the Delphi mailing list