listview 控件(100分)

  • 主题发起人 主题发起人 边城
  • 开始时间 开始时间

边城

Unregistered / Unconfirmed
GUEST, unregistred user!
想要一ListView,能放底图,图小时可指定靠那边,
用过PCANYWHERE 的朋友就知,它的就有这个,

(上次发的进去没内容,怪怪的,这次重发)
 
下载一个(Delphi未经证实的葵花宝典)里面有相关例子!
 
procedure TMain_Form.ListView1CustomDraw(Sender: TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
var
x, y, w, h: LongInt;
begin
if mainbmp = nil then exit;
with mainbmp do begin
W := Width;
H := Height;
end;
Y := 0;
while Y < Height do begin
X := 0;
while X < Width do begin
ListView1.Canvas.Draw(X, Y, mainbmp);
Inc(X, W);
end;
Inc(Y, H);
end;
end;
这个方法是应用程序中的,在控件中,你只要指定一下覆盖原来的方法就可以了
type
Timagelistview = class(Tlistview)
image1 : Timage;
Fmainbmp : Tbitmap;
...
public
mainbmp : Tbitmap read Fmainbmp write Fmainbmp;
end;
constructure create(aowner: Tcompenent);
begin
//此处添加loadpicture的代码比如:表示缺省图片从文件'mainbackimg.bmp‘中来
image1.Picture.LoadFromFile('mainbackimg.bmp');
mainbmp := Tbitmap.create;
mainbmp := image1.Picture.Bitmap;
self.OnCustomDraw := ListView1CustomDraw;
end;

如有疑问,来信yb@powerise.com.cn
 
unit ListViewMain;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics,
Controls, Forms, Dialogs,
ComCtrls, ImgList;
type
TForm1 = class(TForm)
ListView1: TListView;
ImageList1: TImageList;
procedure ListView1CustomDraw(Sender:
TCustomListView;
const ARect: TRect; var DefaultDraw:
Boolean);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Bitmap1: TBitmap;
implementation
{$R *.DFM}

procedure TForm1.ListView1CustomDraw(Sender:
TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
var
x,y,w,h : LongInt;
begin
with Bitmap1 do begin
W := Width;
H := Height;
end;
Y := 0;
while Y < Height do begin
X := 0;
while X < Width do begin
ListView1.Canvas.Draw(X, Y, Bitmap1);
Inc(X, W);
end;
Inc(Y, H);
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Bitmap1 := TBitmap.Create;
Bitmap1.LoadFromFile('backgray.bmp');
end;

procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Bitmap1.Free;
end;

end.
 
后退
顶部