Solved

How to set a  background image into listview?

Posted on 2001-06-11
3
544 Views
Last Modified: 2012-06-27
hi, all
  i want to set a background image into a listview, i've
tried Listview_SetBkImage procedure(i do call CoInitialize before using it),but cant make it work,
would anyone give me a working example? thanx in advance.

 
0
Comment
Question by:receyes
3 Comments
 
LVL 3

Expert Comment

by:MarcG
ID: 6180125
Well, I didn't find SetBKImage with a standard ListView, but you can use the method i just tried ... set owner draw to true and add an image component containing the bmp-Image you want to have as background, then use the OnCustomDraw event to draw the image as background

procedure TForm1.ListView1CustomDraw(Sender: TCustomListView;
  const ARect: TRect; var DefaultDraw: Boolean);
var DestRect, SrcRect : TRect;
begin
  DestRect := Rect(0,0,ListView1.width, Listview1.Height);
  SrcRect := Rect(0,0,Image1.Width,Image1.Height);
  ListView1.Canvas.CopyRect(DestRect,image1.picture.Bitmap.Canvas, SrcRect);
end;

If you want to do it dynamically you can use practically the same. the image with the picture should not be set invisible when copying the image but afterwards you can set it invisible.
You should change it a bit if it doesn't fit exactly your needs.
0
 
LVL 8

Accepted Solution

by:
Cesario earned 200 total points
ID: 6181049
a little bit smaller ;-)

procedure TForm1.ListView1CustomDraw(Sender: TCustomListView;
 const ARect: TRect; var DefaultDraw: Boolean);
Begin
 DestRect := Rect(0,0,ListView1.width, Listview1.Height);
 SrcRect := Rect(0,0,Image1.Width,Image1.Height);
 ListView1.Canvas.CopyRect(Listview1.ClientRect.DestRect,image1.picture.Bitmap.Canvas, Image.ClientRect);
end;

Cesairo
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 9285608
receyes,
No comment has been added lately (814 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to Cesario http:#6181049

Please leave any comments here within 7 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

DragonSlayer
EE Cleanup Volunteer
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Newbie Thread Programming 1 161
Help on project with Soap 10 57
Delphi XE10 Round Image 2 158
how to make 2 step back? ..\..\ ExtractFilePath (paramstr(0)) 5 52
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question