Delphi-Add a progress bar to listview

Source: Internet
Author: User

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
:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.