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 2007 使用shelltreeview控件

Delphi fmx使用 timage 显示动画图片

Delphi指针和字符串

Delphi如何过xp的防火墙而不被拦截

Delphi decodedate、decodetime ... decodedatetime ... 分解时间

Delphi共享软件防破解的实用方法

tstrings 的用法

Delphi case选择语句练习代码简化

Delphi mediaplayer android 下播放 mp4 的问题

Delphi 取16进制字符的10进制的integer值

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



打赏

取消

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

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

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

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

评论

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