unit TransparentScrollListbox;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,extctrls,ScrollListbox;

type
  TTransparentScrollListbox = class(TScrollListBox)
  private
  { Private declarations }
  protected
    { Protected declarations }
  public
  constructor Create(AOwner : TComponent); override;
  procedure CreateParams(var Params: TCreateParams); override;
  procedure Paint; override;
  Procedure WMEraseBkGnd( Var msg: TWMEraseBkGnd );  message WM_ERASEBKGND;
  procedure MouseDown(Button: TMouseButton; Shift: TShiftState;X,Y: Integer); override;
  procedure MouseUp(Button: TMouseButton; Shift: TShiftState;X,Y: Integer); override;
  procedure rb;


      { Public declarations }
  published
     { Published declarations }
  end;


  procedure Register;
implementation


constructor TTransparentScrollListbox.Create(AOwner : TComponent);
begin
inherited Create(AOwner);
  If Parent <> Nil then
    SetWindowLong(Parent.Handle, GWL_STYLE,
       GetWindowLong(Parent.Handle, GWL_STYLE)
          And Not (WS_CLIPCHILDREN or WS_CLIPSIBLINGS));
ControlStyle:= ControlStyle - [csOpaque];
ftransparent:=true;



end;

procedure TTransparentScrollListbox.CreateParams(var Params: TCreateParams);
begin
 inherited CreateParams( params );
  Params.ExStyle := Params.ExStyle + WS_EX_TRANSPARENT;
end;




Procedure TTransparentScrollListbox.WMEraseBkGnd( Var msg: TWMEraseBkGnd );
begin
{setbkmode(self.handle,transparent);
msg.result:=1;    }

end;


procedure TTransparentScrollListbox.paint;
begin
inherited;
end;

procedure TTransparentScrollListbox.MouseDown(Button: TMouseButton; Shift: TShiftState;
  X, Y: Integer);
begin
inherited;
rb;
end;

procedure TTransparentScrollListbox.MouseUp(Button: TMouseButton; Shift: TShiftState;
  X, Y: Integer);
begin
inherited;
rb;
end;


procedure TTransparentScrollListbox.rb;
var
tl,br : tpoint;
tr : trect;
begin
tl.x:=self.left-parent.left;
tl.y:=self.Top-parent.top;
tl:=self.ClientToScreen(tl);
br.x:=self.width+self.left;
br.y:=self.height+self.Top;
br:=self.ClientToScreen(br);

tl:=parent.ScreenToClient(tl);
br:=parent.ScreenToClient(br);

tr.left:=tl.x;
tr.right:=br.x;
tr.top:=tl.y;
tr.Bottom:=br.y;
invalidaterect(parent.handle,@tr,true);
//updatewindow(parent.handle);
end;






procedure Register;
begin
  RegisterComponents('Samples', [TTransparentScrollListbox]);
end;

end.