自绘ListBox的两种效果

本文展示了如何在Delphi中使用TListBox自绘功能实现两种特殊效果:一种灵感来源于C++ Builder,另一种是作者自己的创新。通过TListBox的OnDrawItem事件,结合图像列表、圆角矩形和文字输出,创建了具有选中效果和不同样式的列表项。
摘要由CSDN通过智能技术生成

  本文利用Listbox自绘实现了两种特殊效果(见图),左边的风格是自己突然灵感触发想到的,右边的风格来自"C++ Builder 研究"的一个帖子,老妖用BCB实现了,这里则用Delphi实现它。

演示图片:
自绘ListBox的效果

//--------------------------------------------------------------------------

unit DrawListItem;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ImgList, jpeg, ExtCtrls;

type
  TForm1 = class(TForm)
    lsbRight: TListBox;
    ImageList1: TImageList;
    StaticText1: TStaticText;
    lsbLeft: TListBox;
    imgHouse: TImage;
    imgHouseGray: TImage;
    procedure FormCreate(Sender: TObject);
    procedure lsbRightDrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
    procedure lsbRightClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure lsbLeftDrawItem(Control: TWinControl; Index: Integer;
      Rect: TRect; State: TOwnerDrawState);
  private

  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{========================================================================
  DESIGN BY :  彭国辉
  DATE:        2004-11-29
  SITE:       
http://k

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值