<font color=red>高分求救!!!!!!!!!listview.CustomDraw为其加上了背景图,但item的文字和icon不透明(

  • 主题发起人 主题发起人 xianghb
  • 开始时间 开始时间
X

xianghb

Unregistered / Unconfirmed
GUEST, unregistred user!
&lt;font color=red&gt;高分求救!!!!!!!!!listview.CustomDraw为其加上了背景图,但item的文字和icon不透明(vsicon)(100分)<br />
 
看看这样,还有点问题,改一下吧

procedure TForm1.FormCreate(Sender: TObject);
begin
FBkBmp:=TBitmap.Create;
FBkBmp.LoadFromFile('D:/Shuzi/Resource/图标/背景/Gone Fishing.bmp');
FBKBmp.Transparent:=True;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
FBkBmp.Free;
end;

procedure TForm1.ListView1CustomDraw(Sender: TCustomListView;
const ARect: TRect; var DefaultDraw: Boolean);
begin
Sender.Brush.Bitmap:=FBkBmp;
Sender.Canvas.Brush.Bitmap:=FBkBmp;
Sender.Canvas.FillRect(ARect);
end;


procedure TForm1.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState; var DefaultDraw: Boolean);
var
i,x:integer;
Images:TCustomImageList;
R:TRect;
begin
with Sender as TListView do
begin
if ViewStyle=vsIcon then
Images:=LargeImages
else
Images:=SmallImages;
if Images&lt;&gt;nil then
begin
R:=Item.DisplayRect(drIcon);
ImageList_DrawEx(Images.Handle, Item.ImageIndex, Canvas.Handle,
R.Left+(R.Right-R.Left-Images.Width) div 2,
R.Top+(R.Bottom-R.Top-Images.Height) div 2,0, 0,
clNone, clNone, ILD_Transparent);

end;
R:=Item.DisplayRect(drLabel);
if cdsSelected in State then
begin
Canvas.Brush.Style := bsSolid;
SetTextColor(Canvas.Handle,clWhite);
SetBkColor(Canvas.Handle,clNavy);
SetBkMode(Canvas.Handle,Windows.OPAQUE);
Canvas.TextRect(R,R.Left,R.Top,Item.Caption);
if RowSelect and (ViewStyle=vsReport) then
begin
R:=Item.DisplayRect(drBounds);
R.Left:=R.Left+Columns[0].Width;
Canvas.Brush.Color := clNavy;
Canvas.FillRect(R);
end;
end
else
begin
Canvas.Brush.Style:=bsClear;
SetBkMode(Canvas.Handle,Windows.TRANSPARENT);
Canvas.TextRect(R,R.Left,R.Top,Item.Caption);
end;
if ViewStyle=vsReport then
begin
Canvas.Brush.Style:=bsClear;
SetBkMode(Canvas.Handle,Windows.TRANSPARENT);
R:=Item.DisplayRect(drBounds);
X:=R.Left+Columns[0].Width+Item.Indent;
for i:=0 to Item.SubItems.Count-1 do
begin
Canvas.TextRect(R,X,R.Top,Item.SubItems);
X:=X+Columns[i+1].Width+Item.Indent;
end;
end;
DefaultDraw:=False;
end;
end;
 
接受答案了.
 
请问ImageList_DrawEx函数是怎么回事
 
后退
顶部