Solved

ListView background image

Posted on 2001-08-01
9
1,177 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
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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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
 
LVL 9

Expert Comment

by:ginsonic
ID: 8737388
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 303
Simple Delphi Question 9 89
error 1.1 400 Bad request idhttp delphi 18 86
creating threads in delphi 1 101
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 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