?
Solved

ListView background image

Posted on 2001-08-01
9
Medium Priority
?
1,217 Views
Last Modified: 2007-11-27
  This piece of code "should" set a background image to a TListView. Does anybody know why it does not do it?

const TheFile = 'c:\back.bmp';
var LVBkImg : TLVBkImage;
begin
   OleInitialize (NIL); // Required.

   LVBkImg.ulFlags  := LVBKIF_SOURCE_URL or LVBKIF_STYLE_TILE;
   LVBkImg.pszImage := PChar(TheFile);
   LVBkImg.cchImageMax := Length (TheFile);

   if not ListView_SetBkImage(ListView1.Handle, @LVBkImg) then Showmessage ('NO!');
   ListView_SetTextBkColor(ListView1.Handle, $FFFFFFFF);
end;

   The call to ListView_SetBkImage returns true (everything went ok), but the background image is not shown.

   More over, then next code "should" set the image from a HBITMAP intead of a filename:

var LVBkImg : TLVBkImage;
    b       : TBitmap;
begin
   OleInitialize (NIL); // Required.

   b := TBitmap.Create;
   b.LoadFromFile ('c:\back.bmp');
   LVBkImg.hbm := b.Handle;
   LVBkImg.ulFlags := LVBKIF_SOURCE_HBITMAP or LVBKIF_STYLE_TILE;

   if not ListView_SetBkImage(ListView1.Handle, @LVBkImg) then Showmessage ('NO!');
   ListView_SetTextBkColor(ListView1.Handle, $FFFFFFFF);
end;

   Here, the call to ListView_SetBkImage always returns false.

   They say this functions needs COMCTL32.DLL 4.70 or newer, but I tested it with 5.81 and nothing happened.

0
Comment
Question by:ivan_llanas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 

Expert Comment

by:BryGuy
ID: 6341632
You might want to look at the source to TdfsExtListView from delphifreestuff.com.  There is a background property in it that *somtimes* works apparently - it's disabled by default because he couldn't get it to work all the time either, but it might help you.

Bryan Ashby
0
 
LVL 20

Expert Comment

by:Madshi
ID: 6342141
I can't make it work on my winME, either...   :-(

Regards, Madshi.
0
 
LVL 6

Expert Comment

by:Stuart_Johnson
ID: 6342658
This is from the Delphi 5 example "CustomDraw":

procedure TCustomDrawForm.TVCustomDraw(Sender: TCustomTreeView; const ARect: TRect;
  var DefaultDraw: Boolean);
begin
//This event should be used to draw any background colors or images.
//ARect represents the entire client area of the TreeView.
//Use the TreeView's canvas to do the drawing.
//Note that drawing a background bitmap is not really supported by CustomDraw,
//so scrolling can get messy. Best to subclass the TreeView and handle scrolling
//messages.
  with TV.Canvas do
  begin
    if None1.Checked then //no picture
    begin
      Brush.Color := BkgColorDialog.Color;
      Brush.Style := FBrushStyle;
      FillRect(ARect);
    end else
      if Tile1.Checked then //tile bitmap
      begin
        Brush.Bitmap := Image1.Picture.Bitmap;
          FillRect(ARect);
        end else //Stretch across the canvas.
            StretchDraw(ARect, Image1.Picture.Bitmap);
  end;
  DefaultDraw := FDefaultDraw;
  //setting DefaultDraw to false here prevents all calls to OnCustomDrawItem.
end;

It should be in your $(DELPHI)\Demos directory.

Stu
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:New2Delphi
ID: 6343082
Listening...
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6343305
listening...for moment
0
 

Author Comment

by:ivan_llanas
ID: 6343959
I'm already using a working code that sets the background in a TListView, which uses some of the CustomDraw events and captures some internal TListView messages, a hard piece of code! but eventually have some problems in vsReport ViewStyle. I would like to use this because it's quite simple and I suppose it will be faster (this only if it works some day ;).
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 8735252
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

To be PAQ/Refund

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Thank you,
Russell

EE Cleanup Volunteer
0
 

Accepted Solution

by:
RotaredoM earned 0 total points
ID: 8822648
Finalized as recommended.

Question PAQed and 300 points refunded.

RotaredoM
CS Mod @ EE
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

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