本文利用Listbox自绘实现了两种特殊效果,其中第两种风格来自C Builder 研究 www.ccrun.com,老妖用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://kacarton.yeah.net/
BLOG: http://blog.csdn.net/nhconch
EMAIL: kacarton@sohu.com
文章为作者原创,转载前请先与本人联系,转载请注明文章出处、保留作者信息,谢谢支持!
=========================================================================}
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
begin
lsbRight.Style := lbOwnerDrawFixed;
lsbRight.Ctl3D := false;
lsbRight.ItemHeight := 50;
lsbRight.Items.Add(''''C Builder 研究 www.ccrun.com''''#13''''致力于BCB的学习探讨和研究''''#13''''ccrun(老妖)'''');
lsbRight.Items.Add(''''编程手札 My Developer Knowledge Base''''#13''''http://blog.csdn.net/nhconch''''#13''''天蝎蝴蝶'''');
for i:=3 to 10 do begin
lsbRight.Items.Add(''''ListBox Items of '''' IntTostr(i) #13''''Second of ''''
IntToStr(i) #13''''Third of '''' IntToStr(i));
end;
lsbLeft.Style := lbOwnerDrawFixed;
lsbLeft.Ctl3D := false;
lsbLeft.ItemHeight := 90;
lsbLeft.Items.Add(''''编程手札'''');
lsbLeft.Items.Add(''''My Developer Knowledge Base'''');
lsbLeft.Items.Add(''''站长:天蝎蝴蝶'''');
lsbLeft.Items.Add(''''http://blog.csdn.net/nhconch'''');
end;
procedure TForm1.lsbRightDrawItem(Control: TWinControl; Index: Integer;
文章整理:西部数码--专业提供域名注册、虚拟主机服务
Rect: TRect; State: TOwnerDrawState);
var
strTemp: String;
begin
//文字颜色
lsbRight.Canvas.Font.Color := clBlack;
//设置背景颜色并填充背景
lsbRight.Canvas.Brush.Color := clWhite;
lsbRight.Canvas.FillRect (Rect);
//设置圆角矩形颜色并画出圆角矩形
lsbRight.Canvas.Brush.Color := TColor($00FFF7F7);
lsbRight.Canvas.Pen.Color := TColor($00131315);
lsbRight.Canvas.RoundRect(Rect.Left
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




