J
JacksonLiu
Unregistered / Unconfirmed
GUEST, unregistred user!
各位大侠:
我想在ListView组件上绘制背景图片,采用了如下代码:
var
ABitmap :TBitmap;
procedure TfrmMainWork.FormCreate(Sender: TObject);
begin
......
ABitmap:=TBitmap.Create;
ABitmap.LoadFromFile('back.bmp');
end;
procedure TfrmMainWork.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
......
ABitmap.Free;
end;
在ListView组件的OnCustomDraw事件中采用如下代码:
procedure TfrmMainWork.lvDbListCustomDraw(Sender: TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
var
x,y,w,h :Integer;
begin
with ABitmap do
begin
w:=Width;
h:=Height;
end;
y:=0;
while (y < Height) do
begin
x:=0;
while (x < Width) do
begin
lvDbList.Canvas.Draw(x,y,ABitmap);
Inc(x,w);
end;
Inc(y,h);
end;
end;
结果背景图片是显示出来了,但是当ListView组件中有列表项时,这些列表项
总是不能透明显示(即列表项带有各自的背景色),如何解决这个问题,非常
感谢!
我想在ListView组件上绘制背景图片,采用了如下代码:
var
ABitmap :TBitmap;
procedure TfrmMainWork.FormCreate(Sender: TObject);
begin
......
ABitmap:=TBitmap.Create;
ABitmap.LoadFromFile('back.bmp');
end;
procedure TfrmMainWork.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
......
ABitmap.Free;
end;
在ListView组件的OnCustomDraw事件中采用如下代码:
procedure TfrmMainWork.lvDbListCustomDraw(Sender: TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
var
x,y,w,h :Integer;
begin
with ABitmap do
begin
w:=Width;
h:=Height;
end;
y:=0;
while (y < Height) do
begin
x:=0;
while (x < Width) do
begin
lvDbList.Canvas.Draw(x,y,ABitmap);
Inc(x,w);
end;
Inc(y,h);
end;
end;
结果背景图片是显示出来了,但是当ListView组件中有列表项时,这些列表项
总是不能透明显示(即列表项带有各自的背景色),如何解决这个问题,非常
感谢!