zoukankan      html  css  js  c++  java
  • Delphi 在ListView中添加一个进度条

    看CxGrid资料的时候,看见了一个为兄弟的文章,我就转一下了.


    //需要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
    l_Rect: TRect ;
    l_intPercent: Integer ;
    Begin
    If SubItem = 3 Then
    Begin
    If Item.Data = Nil Then
    Exit ;
    l_intPercent := PListData( Item.Data ).Percent ;
    //获取ListView子项的Rect
    l_Rect := GetSubItemRect( Item.Handle, Item.Index, SubItem ) ;
    //画一条外边框
    InflateRect( l_Rect, -1, -1 ) ;
    Sender.Canvas.Brush.Color := clBlack ;
    Sender.Canvas.FrameRect( l_Rect ) ;
    //先填充底色
    InflateRect( l_Rect, -1, -1 ) ;
    Sender.Canvas.Brush.Color := lvw_list.Color ;
    Sender.Canvas.FillRect( l_Rect ) ;
    //再根据进度画出完成区域
    If l_intPercent = 100 Then
    Sender.Canvas.Brush.Color := clGreen
    Else
    Sender.Canvas.Brush.Color := clPurple ;
    l_Rect.Right := l_Rect.Left + Floor( ( l_Rect.Right - l_Rect.Left ) * l_intPercent / 100 ) ;
    Sender.Canvas.FillRect( l_Rect ) ;
    //恢复笔刷
    Sender.Canvas.Brush.Color := lvw_list.Color ;
    //关键的一句,屏蔽系统自绘过程
    DefaultDraw := False ;
    End ;
    End ;
    相关定义
    Type
    TListData = Record
    FileName: String ;
    Percent: Integer ;
    End ;
    PListData = ^TListData ;
      本文来自CSDN博客,转载请标明出处:http: //blog.csdn.net/kwbin/archive/2008/11/26/3381317.aspx
    效果图:
    2008-11-26_173648
  • 相关阅读:
    docker 容器
    web开发相关工具总结
    Linux] Git: push 出错的解决 master -> master (branch is currently checked out)
    MongoDB
    vs code 快捷键
    flutter 实现圆角头像的2种方法
    Flutter web环境变量搭建及开发
    使用VS Code调试Flutter(检查用户页面)
    Flutter走过的坑(持续更新)
    react link引入外部css样式的坑
  • 原文地址:https://www.cnblogs.com/huangjacky/p/1619791.html
Copyright © 2011-2022 走看看