我的程序中使用了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;

解决方案 »

  1.   

    <a href=http://qqshow.qq.com/cgi-bin/qqshow_user_info?uin=QQ号码><img src=http://qqshow-user.tencent.com/1295542/10/00/></a>
    关注中!
      

  2.   

    procedure TForm1.lvCustomDrawItem(Sender: TCustomListView; Item: TListItem;
      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处理
      

  3.   

    lijinghe1(副乡长):用你的代码后,图标就看不见啦。。
    能否给出更详细的代码?多谢。
    分不够可以再加。另外,在ListView中实现像QQ那样头像闪烁的功能,有没什么高见?
      

  4.   

    关于头像闪烁问题,我另外开了一个帖子:
    http://community.csdn.net/Expert/topic/3081/3081167.xml?temp=.2907984
      

  5.   

    if lv.SmallImages <> nil then begin
        lv.SmallImages.Draw(lv.Canvas,0,r.top,Item.imageindex);
      end;
    没用过qq