[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to set a  background image into listview?

Posted on 2001-06-11
3
Medium Priority
?
607 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 800 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

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

830 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