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 byte数组根据utf8 转换为string

Delphi下载指定网址(url)的文件,带进度条显示

Delphi中用idhttp获取json数据乱码问题

Delphi根据网络链接截取域名

Delphi'控件的相对坐标与屏幕坐标转换

Delphi 无边框窗体常见问题

Delphi 获取路径分隔符

Delphi 下载并显示网上的图片

Delphi pchar与string互转

Delphi中禁止webbrowser右键的方法

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



打赏

取消

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

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

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

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

评论

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