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 ttabcontrol

Delphi 单击按钮左键弹起菜单

Delphi 的内存操作函数(3): 给结构体指针分配内存

Delphi 刷新桌面函数

Delphi 递归实现从m 个集合中 任取一个元素 生成组合

Delphi 比较版本号

Delphi在字符串中删除指定字符串

Delphi zlib 流压缩解压

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



打赏

取消

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

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

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

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

评论

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