[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ListView background image

Posted on 2001-08-01
9
Medium Priority
?
1,256 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

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…
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 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…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month19 days, 14 hours left to enroll

873 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