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