自绘ListBox的两种效果

2008-04-10 02:56:51来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

  本文利用Listbox自绘实现了两种特殊效果,其中第两种风格来自C Builder 研究 www.ccrun.com,老妖用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://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

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:制作从屏幕右下角逐渐弹出的消息提示框

下一篇:自定义Delphi 2005的Welcome page