Solved

How to set a  background image into listview?

Posted on 2001-06-11
3
524 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now