[DUG] Listview selected highlight

Ross Levis ross at stationplaylist.com
Fri Nov 30 10:41:52 NZDT 2007


Thanks for that.  I considered working out how to draw it myself but then
thought Windows may still control the selection.

I'll need to do the same with OnCustomDrawSubitem.  I have RowSelect set to
true.  I presume the item and subitems rectangles will join together in this
case so there is one continuous selection.  I'll have to have a play.

Cheers,
Ross.

-----Original Message-----
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz] On
Behalf Of Jeremy North
Sent: Friday, 30 November 2007 3:23 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Listview selected highlight

Just do all the drawing yourself.

ie:

procedure TForm19.ListView1CustomDrawItem(Sender: TCustomListView;
Item: TListItem; State: TCustomDrawState;
  var DefaultDraw: Boolean);
var
  lRect: TRect;
  lFlags: Cardinal;
begin
  lRect := Item.DisplayRect(drLabel);
  ListView1.Canvas.Brush.Style := bsSolid;
  ListView1.Canvas.Brush.Color := clYellow;
  ListView1.Canvas.FillRect(lRect);
  ListView1.Canvas.Font.Color := clRed;
  lFlags := DT_SINGLELINE or DT_CENTER or DT_VCENTER;
  DrawText(ListView1.Canvas.Handle, PChar(Item.Caption),
Length(Item.Caption), lRect, lFlags);
  DefaultDraw := False;
end;


On Nov 29, 2007 9:32 PM, Ross Levis <ross at stationplaylist.com> wrote:
>
>
>
> Anyone know if it's possible to prevent a listview from showing the
selected
> highlight colour on selected items?
>
>
>
> I want to display a specific brush colour depending on the type of item,
> which I do with OnCustomDrawItem, but the colour only displays when I move
> the focus away from the listview.  It goes back to the usual blue colour
> when the listview gets the focus again.
>
>
>
> I'm trying to find a Windows parameter to use in CreateParams, or even
> modify the ComCtrls unit if necessary, but I can't a way to do it.
>
>
>
> Thanks,
>
> Ross.
> _______________________________________________
> NZ Borland Developers Group - Delphi mailing list
> Post: delphi at delphi.org.nz
> Admin: http://delphi.org.nz/mailman/listinfo/delphi
> Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
> unsubscribe
>
_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: delphi at delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-request at delphi.org.nz with Subject:
unsubscribe



More information about the Delphi mailing list