title: Why my scrollbar is not always painted correctly?
body: <p>I have a graphical <code>TCustomControl</code> descendant component with a system scrollbar on it. The problem is that when I move the window half outside the screen and then I drag it back, the scrollbar disappers (it's not painted). How can I fix this ? I'm thinking, maybe I should call the scrollbar <code>Paint</code> method in component <code>Paint</code> but I don't know how.</p>
  
  <p>Here is the code. There is no need install the component or to put something on the main form, just copy the code and assign <code>TForm1.FormCreate</code> event:</p>
  
  <p><strong>Unit1.pas</strong></p>
  
  <pre><code>unit Unit1;
  
  interface
  
  uses
    Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
    Dialogs, SuperList;
  
  type
    TForm1 = class(TForm)
      procedure FormCreate(Sender: TObject);
    end;
  
  var
    Form1: TForm1;
    List: TSuperList;
  
  implementation
  
  {$R *.dfm}
  
  procedure TForm1.FormCreate(Sender: TObject);
  begin
   List:=TSuperList.Create(self);
   List.AlignWithMargins:=true;
   List.Align:=alClient;
   List.Visible:=true;
   List.Parent:=Form1;
  end;
  
  end.
  </code></pre>
  
  <p><strong>SuperList.pas</strong></p>
  
  <pre><code>unit SuperList;
  
  interface
  
  uses Windows, Controls, Graphics, Classes, Messages, SysUtils, StdCtrls, Forms;
  
  type
  
    TSuperList = class(TCustomControl)
    public
      DX,DY: integer;
      procedure   Paint; override;
      constructor Create(AOwner: TComponent); override;
      procedure   WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
      procedure   CreateParams(var Params: TCreateParams); override;
    published
      property    TabStop default true;
      property    Align;
    end;
  
  procedure Register;
  
  implementation
  
  procedure Register;
  begin
    RegisterComponents('Marus', [TSuperList]);
  end;
  
  procedure TSuperList.CreateParams(var Params: TCreateParams);
  begin
    inherited;
    Params.Style := Params.Style or WS_VSCROLL;
  end;
  
  procedure TSuperList.WMLButtonDown(var Message: TWMLButtonDown);
  begin
   DX:=Message.XPos;
   DY:=Message.YPos;
   Invalidate;
   inherited;
  end;
  
  constructor TSuperList.Create(AOwner: TComponent);
  begin
   inherited;
   DoubleBuffered:=true;
   TabStop:=true;
   Color:=clBtnFace;
   BevelKind:=bkFlat;
   Width:=200; Height:=100;
   DX:=50; DY:=50;
  end;
  
  procedure TSuperList.Paint;
  begin
   Canvas.Brush.Color:=clWindow;
   Canvas.FillRect(Canvas.ClipRect);
   Canvas.TextOut(10,10,'Press left mouse button !');
   Canvas.Brush.Color:=clRed;
   Canvas.Pen.Color:=clBlue;
   Canvas.Rectangle(DX,DY,DX+30,DY+20);
  end;
  
  end.
  </code></pre>