我的程序中使用了ListView控件,并且用代码在ListView的底部绘制了背景,这样有个问题,ListView中显示的图标及文字是不透明的,很是难看。哪位大虾知道该如何让图标及文字透明?
绘制背景的代码如下:在ListView的OnCustomDraw事件下加入如下代码:
Var
x,y,w,h : LongInt;
begin
with Image2.Picture.Bitmap do begin
W := Width;
H := Height;
end;
Y := 0;
while Y < Height do begin
X := 0;
while X < Width do begin
lv.Canvas.Draw(X, Y, Image2.Picture.Bitmap);
Inc(X, W);
end;
Inc(Y, H);
end;
end;
绘制背景的代码如下:在ListView的OnCustomDraw事件下加入如下代码:
Var
x,y,w,h : LongInt;
begin
with Image2.Picture.Bitmap do begin
W := Width;
H := Height;
end;
Y := 0;
while Y < Height do begin
X := 0;
while X < Width do begin
lv.Canvas.Draw(X, Y, Image2.Picture.Bitmap);
Inc(X, W);
end;
Inc(Y, H);
end;
end;
关注中!
State: TCustomDrawState; var DefaultDraw: Boolean);
var
i ,iLeft: Integer;
r : TRect;
begin
r := Item.DisplayRect(drLabel);
DefaultDraw := False;
lv.Canvas.Brush.Style := bsClear ;
lv.Canvas.TextRect(r,r.Left,r.Top,Item.Caption);
iLeft := r.Right;
for i := 0 to Item.SubItems.Count -1 do begin
lv.Canvas.TextOut(iLeft,r.Top,Item.SubItems[i]);
iLeft := iLeft + lv.Columns[i+1].Width;
end;
end;
实现选择等状态可根据State处理
能否给出更详细的代码?多谢。
分不够可以再加。另外,在ListView中实现像QQ那样头像闪烁的功能,有没什么高见?
http://community.csdn.net/Expert/topic/3081/3081167.xml?temp=.2907984
lv.SmallImages.Draw(lv.Canvas,0,r.top,Item.imageindex);
end;
没用过qq