Solved

How to set a  background image into listview?

Posted on 2001-06-11
3
528 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 285
Reconfigure Delphi Install? 2 45
tidtcpserver connection lost handle 2 70
Firemonkey webbrowser scrollbars ? 1 29
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

911 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

20 Experts available now in Live!

Get 1:1 Help Now