给LISTVIEW加背景图

Delphi 专栏收录该内容
3 篇文章 0 订阅

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, commctrl, ImgList;

type
  TForm1 = class(TForm)
    ListView1: TListView;
    ImageList1: TImageList;
    procedure ListView1CustomDraw(Sender: TCustomListView;
      const ARect: TRect; var DefaultDraw: Boolean);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure ListView1Resize(Sender: TObject);
  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: LongInt;
begin
  x := self.Width - bitmap1.Width;
  y := self.Height - bitmap1.Height;
  self.Caption := inttostr(form1.Width) + ',' + inttostr(x);
  listview1.Canvas.Draw(x, y, bitmap1);
  SetBkMode(listview1.Canvas.Handle,TRANSPARENT);
  ListView_SetTextBKColor(listview1.Handle,CLR_NONE);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Bitmap1 := TBitmap.Create;
  Bitmap1.LoadFromFile('backgray.bmp');
  listview1.Align := alclient;
  listview1.DoubleBuffered := true;
  ShowScrollBar(listview1.Handle, SB_BOTH ,false);
end;

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

procedure TForm1.ListView1Resize(Sender: TObject);
begin
  listview1.Invalidate;
end;

end.

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值