When reading the cxgrid information, I saw a brotherArticleI will go over it.
// Use commctrl
Function Getsubitemrect (handle, itemsindex, subindex: integer): trect;
Begin
Listview_getsubitemrect (handle, itemsindex, subindex, 0, @ result );
End ;
Procedure Tformmain. lvw_listcustomdrawsubitem (Sender: tcustomlistview;
Item: tlistitem; subitem: integer; State: tcustomdrawstate;
VaR Defaultdraw: Boolean );
VaR
Rochelle rect: trect;
Rochelle intpercent: integer;
Begin
If Subitem = 3
Then
Begin
If Item. Data =
Nil
Then
Exit;
Rochelle intpercent: = plistdata (item. Data). percent;
// Obtain the rect of the listview subitem
Rochelle rect: = getsubitemrect (item. Handle, item. index, subitem );
// Draw an outer border
Inflaterect (l_rect,-1,-1 );
Sender. Canvas. Brush. Color: = clblack;
Sender. Canvas. framerect (l_rect );
// Fill the background color first
Inflaterect (l_rect,-1,-1 );
Sender. Canvas. Brush. Color: = lvw_list.color;
Sender. Canvas. fillrect (l_rect );
// Draw the completion area based on the Progress
If Rochelle intpercent = 100
Then
Sender. Canvas. Brush. Color: = clgreen
Else
Sender. Canvas. Brush. Color: = clpurple;
Rochelle rect.right: = Rochelle rect.left + floor (Rochelle rect.right-Rochelle rect.left) * Rochelle intpercent/100 );
Sender. Canvas. fillrect (l_rect );
// Restore the brush
Sender. Canvas. Brush. Color: = lvw_list.color;
// A key sentence to block the system self-Painting Process
Defaultdraw: = false;
End ;
End ;
Definition
Type
Tlistdata =
Record
Filename:
String ;
Percent: integer;
End ;
Plistdata = ^ tlistdata;
This article is from the csdn blog. For more information, see http:
// Blog.csdn.net/kwbin/archive/2008/11/26/3381317.aspx
: