delphi listbox用Canvas属性绘图


本文整理自网络,侵删。

 
示例 delphi listbox用Canvas属性绘图
procedure TForm1.ListBox1DrawItem(Control: TWinControl; Index: Integer;
  Rect: TRect; State: TOwnerDrawState);
var
  i:integer;
begin
  with Control as TListBox do
  begin
    Canvas.FrameRect(Clientrect);
    if odSelected in State then
    begin
      Canvas.Brush.Color:=clRed;
      Canvas.RoundRect(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom,8,15);
      setBkMode(Canvas.Handle,TRANSPARENT    );
      Canvas.TextOut((Rect.right-Rect.Left) div 2,Rect.Top,Items.Strings[Index]);
    end
    else
    begin
      Canvas.Brush.Color:=clSkyBlue;
      Canvas.RoundRect(Rect.Left,Rect.Top,Rect.Right,Rect.Bottom,15,15);
      Canvas.TextRect(Rect,Rect.Left,Rect.Top,Items.Strings[Index]);
    end;
  end;
end;

相关阅读 >>

Delphi 实现文件拖放完整代码

Delphi模拟文件拖拽

Delphi 泛型,存放n张图片

Delphi float转换int

Delphi 的 webservice 的 cookie 操作

Delphi调用rest

Delphi 判断文本文件是否utf-8编码

什么是嵌入式数据库

Delphi+access错误"不正常地定义参数对象。提供了不一致或不完整的信息。"

Delphi 从网页里下载图片的程序

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...