我按照透明listbox控件 想做一个透明的 listview 控件
但是控件放到窗体上是透明的 但是不显示字 必须点一下才出来 而且 item 还是白色的
下面是代码 请各位高手指点一二
unit mylistview;interfaceuses
  Windows,Messages,Forms,Graphics,SysUtils, Classes, Controls, ComCtrls;type
  Tmylistview = class(TListView)
  private
    { Private declarations }
  protected
    { Protected declarations }
    procedure CreateParams(var Params: TCreateParams); override;
    procedure WMEraseBkgnd(var Msg: TWMEraseBkgnd); message WM_ERASEBKGND;
    procedure DrawItem(Item: TListItem; Rect: TRect; State: TOwnerDrawState); override;
  public
    { Public declarations }
    constructor Create(AOwner:TComponent);override;
    procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
  published
    { Published declarations }    property ViewStyle default vsReport;
    property Ctl3D default False;
    property BorderStyle default bsNone;
    property RowSelect default True;
  end;procedure Register;implementationprocedure Register;
begin
  RegisterComponents('Plus', [Tmylistview]);
end;{ Tmylistview }constructor Tmylistview.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Ctl3D       := False;
  BorderStyle := bsNone;
  ViewStyle       := vsReport;
  RowSelect := True;
end;procedure Tmylistview.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  with Params do
  begin
  { 完全重画 }
    //Style := Style and not WS_CLIPCHILDREN;
    //Style := Style and not WS_CLIPSIBLINGS;
  { 增加透明 }
    ExStyle := ExStyle or WS_EX_TRANSPARENT;
  end;
end;procedure Tmylistview.DrawItem(Item: TListItem; Rect: TRect;State: TOwnerDrawState);
var
FoundStyle: TBrushStyle;
R: TRect;
begin
FoundStyle := Canvas.Brush.Style;       // Remember the brush style
R := Rect;                                     // Adapt coordinates of drawing rect...
MapWindowPoints(Handle, Parent.Handle, R, 2);  // ... to parent's coordinate system
InvalidateRect(Parent.Handle, @R, True);   // Tell parent to redraw the item Position
Parent.Update;                             // Trigger instant redraw(required)
if not (odSelected in State) then
begin  // If an unselected line is being
//handled
Canvas.Brush.Style := bsClear;  //   use a transparent background
end
else
begin                          // otherwise, if the line needs to be
//highlighted,
Canvas.Brush.Style := bsSolid;  //   some colour to the brush is essential
end;
inherited DrawItem(Item, Rect, State); // Do the regular drawing and give component users...
// ... a chance to provide an OnDrawItem handler
Canvas.Brush.Style := FoundStyle;  // Boy-scout rule No. 1: leave site as you found it
end;procedure Tmylistview.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
var
tlbVisible: Boolean;
begin
tlbVisible := (Parent <> nil) and IsWindowVisible(Handle);  // Check forvisibility
if tlbVisible then ShowWindow(Handle, SW_HIDE);             // Hide-Move-Shows trategy...
inherited SetBounds(ALeft, ATop, AWidth, AHeight);          // ... to prevent background...
if tlbVisible then ShowWindow(Handle, SW_SHOW);             // ... from getting copied
end;procedure Tmylistview.WMEraseBkgnd(var Msg: TWMEraseBkgnd);
begin
Msg.Result := 1;
end;end.