Can anyone help me please, either on how to do it myself (prefable) or point
me in the direction of a component :)
Many Thanks
Regards
Steve Childs.
http://www.delphifreestuff.com/cgi-bin/dfs_components.cgi?extlistview
--
Thanks,
Jon.
Steve Childs <st...@childs-play-software.co.uk> wrote in message
news:7unqgk$8f...@forums.borland.com...
It should but whether it actually does will depend on the common control DLL
version on your system (requires 4.71 at min). But there may be another
thing you have to do. The MSDN docs have this comment for LVM_SETBKIMAGE:
"Because the list view control uses OLE COM to manipulate the background
images, the calling application must call CoInitialize or OleInitialize before
sending this message. It is best to call one of these functions when the
application is initialized and call either CoUninitialize or OleUninitialize
when the application is terminating. "
If you do not use other COM/OLE stuff in your app you have to call
CoInitialize manually. Try that first, it is practically hopeless to get a
background image to work well on a standard Windows control that has no
build-in support for that.
Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!
Thanks anyway.
Regards
Steve
Jon E. Scott <jsc...@landstar.com> wrote in message
news:7uq94r$qh...@forums.borland.com...
> Does Brad Stower's TdfsExtListView do what you want?
>
> http://www.delphifreestuff.com/cgi-bin/dfs_components.cgi?extlistview
>
> --
> Thanks,
> Jon.
>
>
> Steve Childs <st...@childs-play-software.co.uk> wrote in message
> news:7unqgk$8f...@forums.borland.com...
> > Hi, I'm trying desperatly(!) to get a background bitmap to be displayed
in
> > the background of a ListView. I've tried drawing it myself with
> > WM_ERASEBKGND, and it works fine-ish, until the user resizes the column
(not
> > to mention the text screws up). I tried using LVM_SETBKIMAGE but they
want a
> > URL to a file (daft?). To satisfy that, I tried making a url to a file
on
> > disk (i.e. file://C:\Temp\a.bmp) and various variations on the theme, it
> > just won't work.
> >
You can get a listview with a background bitmap as part of my GXExplorer
source code at http://www.gexperts.com/gxexplorer. You can use this
component free of charge providing your not using it in a file manager style
application.
Gerald
--
Thanks,
Jon.
Steve Childs <st...@childs-play-software.co.uk> wrote in message
news:7usgni$eo...@forums.borland.com...
What I want to do is very simple, my program uses a ListView. The thing is
my program is skinnable, so the ugly listview do not looks good on the
skins, I was wondering if is there a way to make it transparent so it shows
the skin as it should be.
Is it possible to do this?
And how ?
Thanks
Chris
Windows does not support transparency well. There is an WS_EX_TRANSPARENT
extended window style but it does not work too well on controls that change their
contents all the time, scroll, stuff like that. Your best bet would really be
to copy the part of the skin bitmap as background bitmap to the control, if you
can get its build-in support for that to work.
I have followed your advice, but I can seem to make this thing work. First,
how can I copy the bitmap and put it on the listview?
This is very difficult and I'm frying my brain here... can you give me some
pointers in where to search for this issue (or would you happen to have some
code of it?)
Thanks and sorry for the trouble again...
Chris
Peter Below (TeamB) <10011...@compuXXserve.com> escribió en el mensaje de
noticias VA.00003eeb.00d6eafd@noname...
You copy parts of a bitmap to another using the target bitmaps
canvas.copyrect method.
Var
target: TBitmap;
Begin
target :=TBitmap.Create;
target.Width := ....;
target.Height := ....;
target.Canvas.Copyrect(
target.Canvas.Cliprect,
sourcebitmap.canvas,
sourcerect );
On a 256 color video mode you may also need to copy the source bitmaps
palette.
I have no idea how you would put it on the listview using LVM_SETBKIMAGE. The
docs indicate that you have to provide an URL for the file to use, so you
will need to save the bitmap to a file. The MSDN docs are exceedingly sparse
on this feature and do not indicate which kinds of images (JPEG, GIF, BMP
probably) are acceptable. Go to www.deja.com and conduct a search on
Listview_SetBkImage and LVM_SETBKIMAGE, perhaps you will find something in
other newsgroups, even if its in C.
I've made this component. It works fine if I create it at run time, but if I
drop it on the form at design time when you run on a program, it loses the
background. Also, in the report mode, it doesnt show the ListView item you
clicked on...
I leave you the code for you to check it out.
Thanks in advance ...
unit translistview;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls;
type
TVScrollEventType = (vsLineUp, vsLineDown, vsPageUp, vsPageDown,
vsThumbPos,
vsThumbTrack, vsTop, vsBottom, vsEndScroll);
THScrollEventType = (hsLineLeft, hsLineRight, hsPageLeft, hsPageRight,
hsThumbPos, hsThumbTrack, hsLeft, hsRight,
hsEndScroll);
TVScrollEvent = procedure(Sender : TObject; Pos : SmallInt; EventType :
TVScrollEventType)
of Object;
THScrollEvent = procedure(Sender : TObject; Pos : SmallInt; EventType :
THScrollEventType)
of Object;
TTransListView = class (TListView)
private
FOnVScroll : TVScrollEvent;
FOnHScroll : THScrollEvent;
FCopy:Boolean;
FBitmap:TBitmap;
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message
WM_ERASEBKGND;
procedure WMVScroll(var Message : TWMScroll); message WM_VSCROLL;
procedure WMHScroll(var Message : TWMScroll); message WM_HSCROLL;
protected
procedure VScroll(Pos : Integer; EventType : TVScrollEventType) ;
Virtual;
procedure HScroll(Pos : Integer; EventType : THScrollEventType) ;
Virtual;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Draw(Sender: TCustomListView; const ARect: TRect; var
DefaultDraw: Boolean);
property OnVerticalScroll : TVScrollEvent read FOnVScroll write
FOnVScroll;
property OnHorizontalScroll : THScrollEvent read FOnHScroll write
FOnHScroll;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples', [TTransListView]);
end;
procedure TTransListView.WMEraseBkgnd(var Message: TWMEraseBkgnd);
begin
if not FCopy then
begin // just make the copy the first time through
FBitmap.Width:=Width;
FBitmap.Height:=Height;
BitBlt(FBitmap.Canvas.Handle,0,0,Width,Height,(Owner as
TForm).Canvas.Handle,Left,Top,SRCCOPY);
end;
FCopy:=True;
inherited;
end;
constructor TTransListView.Create(AOwner: TComponent);
begin
inherited;
FBitmap:=TBitmap.Create;
OwnerDraw:=True;
OnCustomDraw:=Draw;
FOnVScroll := nil;
FOnHScroll := nil;
end;
destructor TTransListView.Destroy;
begin
FBitmap.Free;
inherited;
end;
procedure TTransListView.Draw(Sender: TCustomListView; const ARect: TRect;
var DefaultDraw: Boolean);
begin // I tried to override the CustomDraw procedure but couldn't get it
to work
BitBlt(Canvas.Handle, ARect.Left, ARect.Top, ARect.Right-ARect.Left,
ARect.Bottom-ARect.Top, fBitmap.Canvas.Handle, ARect.Left, ARect.Top,
SRCCOPY);
DefaultDraw:=True; // had to offset the bitmap placement by two (top &
bottom) because of border
end;
procedure TTransListView.HScroll(Pos: Integer;
EventType: THScrollEventType);
begin
if assigned(FOnHScroll) then
FOnHScroll(Self, Pos, EventType);
end;
procedure TTransListView.VScroll(Pos: Integer;
EventType: TVScrollEventType);
begin
if assigned(FOnVScroll) then
FOnVScroll(Self, Pos, EventType);
end;
procedure TTransListView.WMHScroll(var Message: TWMScroll);
var
EventType : THScrollEventType;
begin
inherited;
EventType := THScrollEventType(Message.ScrollCode);
if EventType in [hsLineLeft, hsLineRight, hsPageLeft, hsPageRight,
hsThumbPos, hsThumbTrack, hsLeft, hsRight, hsEndScroll]
then
begin
HScroll(Message.Pos, EventType);
Repaint;
end;
{else
VScroll(VertScrollBar.;}
end;
procedure TTransListView.WMVScroll(var Message: TWMScroll);
var
EventType : TVScrollEventType;
begin
inherited;
EventType := TVScrollEventType(Message.ScrollCode);
if EventType in [vsLineUp, vsLineDown, vsPageUp, vsPageDown, vsThumbPos,
vsThumbTrack, vsTop, vsBottom, vsEndScroll] then
begin
VScroll(Message.Pos, EventType);
Repaint;
end;
{else
VScroll(VertScrollBar.;}
end;
end.
What is wrong with this?
>It works fine if I create it at run time, but if I
>drop it on the form at design time when you run on a program, it loses the
>background
I can't give you any specific advice about the TListView. However, I
can point out something about form-resident vs. dynamically create
components that might be relevant here. Components on the form will
be streamed in during the form creation process. This action involves
a call to the component's Loaded method late in the game.
It's possible to have a setting made in Create altered in Loaded,
particularly when there's a design-time property setting that
overrides a property value initialization done in Create. Dynamically
created components don't get a Loaded call, so any Create
initializations couldn't be altered in this case.
By the way, it's generally not a good idea for the component to
appropriate a published event for its own internal use. That opens
the door to the very sort of problem described above. Besides, it's
also considered very rude <g>.
A better solution would be to derive your component from
TCustomListView. You'll then need to declare all the user-setable
properties as published. But this way you could decline to declare
OnCustomDraw as such. This way the component gets to keep the event
to itself and there's no conflict.
Regards,
D.B.
"Christian E. Strevel" wrote:
>
> There was a problem with the posting, so I attached the full unit into the
> message. It's not big...
>
> Christian E. Strevel <kr...@cyberdude.com> escribió en el mensaje de
> noticias 7vr7oc$q0...@forums.borland.com...
> > Ok guys
> >
> > I've made this component. It works fine if I create it at run time, but if
> I
> > drop it on the form at design time when you run on a program, it loses the
> Name: translistview.pas
> translistview.pas Type: Delphi Unit (application/x-unknown-content-type-DelphiUnit)
> Encoding: x-uuencode
--
Jeff Overcash (TeamB)
(Please do not email me directly unless asked. Thank You)
Anyone who cannot cope with mathematics is not fully human.
At best he is a tolerable subhuman who has learned to wear
shoes, bathe and not make messes in the house. (Heinlein)