请详细赐教。

解决方案 »

  1.   

    implementation
     uses Jpeg;
    {$R *.dfm}procedure TForm1.BitBtn1Click(Sender: TObject);
    var
      jpg:TJPEGImage;
    begin
      jpg:= TJpegImage.Create;
      jpg.LoadFromFile('C:\Documents and Settings\Administrator\My Documents\My Pictures\0091.jpg');
     // Listview1.Canvas.Draw(0,0,jpg);
      Listview1.Canvas.StretchDraw(Listview1.Canvas.ClipRect,jpg);
      jpg.Free;
    end;
      

  2.   

    楼上的:这样好像不行,当屏幕重绘时就有了问题,看我下面的程序(不行的,会盖住ListView.Items):
    procedure TFrm_BackGround.Btn_ApplyClick(Sender: TObject);
    var
        Rect: TRect;
        x,y,w,h: LongInt;
        BmpWidth, BmpHeight: Integer;
        PosLeft, PosTop: Integer;
        FileName: String;
    begin
        if BackFileName = '' then  //使用无图片有颜色模式
            Frm_Main.ListView1.Color := BackColor
        else
        begin
            BackGroundBmp := TBitMap.Create;
            BackGroundBmp.LoadFromFile(BackFileName);
            if Cmb_Pos.ItemIndex = 0 then  //居中
            begin
                PosLeft := round((ScreenWidth - BackGroundBmp.Width)/2);
                PosTop  := round((ScreenHeight - BackGroundBmp.Height)/2);
                Rect.Left := PosLeft;
                Rect.Top := PosTop;
                Rect.Right := PosLeft + BackGroundBmp.Width;
                Rect.Bottom := PosTop + BackGroundBmp.Height;
                Frm_Main.ListView1.Canvas.StretchDraw(Rect, BackGroundBmp);
            end
            else if Cmb_Pos.ItemIndex = 1 then   //拉伸
            begin
                Rect.Left := Frm_Main.ListView1.Left;
                Rect.Top := Frm_Main.ListView1.Top;
                Rect.Right := Frm_Main.ListView1.Left + Frm_Main.ListView1.Width;
                Rect.Bottom := Frm_Main.ListView1.Top + Frm_Main.ListView1.Height;
                Frm_Main.ListView1.Canvas.StretchDraw(Rect, BackGroundBmp);
            end
            else if Cmb_Pos.ItemIndex = 2 then  //平铺
            begin
                w := BackGroundBmp.Width;
                h := BackGroundBmp.Height;            y := 0;
                while y < Frm_Main.ListView1.Height do
                begin
                    x := 0;
                    while x < Frm_Main.ListView1.Width do
                    begin
                        Frm_Main.ListView1.Canvas.Draw(x, y, BackGroundBmp);
                        Inc(x, w);
                    end;
                Inc(y, h);
                end;
            end;
            FileName := ExtractFilePath(Application.ExeName)+'BackGround\' + ExtractFileName(BackFileName);
            if not FileExists(FileName) then
            begin
                CopyFile(PChar(BackFileName), PChar(FileName), true);
                FormCreate(Sender);
            end;
        end;
        Btn_Apply.Color := clBtnFace;
        bApply := true;
    end;
      

  3.   

    改写TListView控件,增加FPicture属性并自动刷新,调用API 
    SetBkMode(Canvas.Handle,TRANSPARENT);
    ListView_SetTextBKColor(Handle,CLR_NONE);