unit ColorListBox1;
interface
uses
SysUtils, Classes, Controls, StdCtrls, Graphics, Windows, Messages;
type
TScroll =
class(TGraphicsObject)
private
FVisible : Boolean;
FLength : Integer;
procedure SetVisible(Value : Boolean);
procedure SetLength (Value : Integer);
protected
public
constructor Create;
published
property Visible : Boolean
read FVisible
write SetVisible
default False;
property Length : Integer
read FLength
write SetLength
default 0;
end;
MyColorListBox1 =
class(TListBox)
private
{ Private-Deklarationen }
FScrollbar : TScroll;
procedure SetScrollBar (Value : TScroll);
protected
{ Protected-Deklarationen }
public
{ Public-Deklarationen }
constructor Create(AOwner:TComponent);
override;
destructor Destroy;
override;
published
{ Published-Deklarationen }
property Scrollbar : TScroll
read FScrollbar
write SetScrollBar;
end;
procedure Register;
{ ----------------------------------------------------------------------------- }
implementation
{ ----------------------------------------------------------------------------- }
procedure Register;
begin
RegisterComponents('
Beispiele', [MyColorListBox1]);
end;
{ ----------------------------------------------------------------------------- }
{ ColorListBox1 }
{ ----------------------------------------------------------------------------- }
constructor MyColorListBox1.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Width := 100;
Height := 100;
FScrollbar := TScroll.Create;
end;
{ ----------------------------------------------------------------------------- }
destructor MyColorListBox1.Destroy;
begin
FScrollbar.Free;
inherited Destroy;
end;
{ ----------------------------------------------------------------------------- }
{ TScroll }
{ ----------------------------------------------------------------------------- }
constructor TScroll.Create;
begin
inherited Create;
FVisible := False;
FLength := 0;
end;
{ ----------------------------------------------------------------------------- }
procedure TScroll.SetLength(Value: Integer);
begin
if Value <> 0
then
FLength := Value;
end;
{ ----------------------------------------------------------------------------- }
procedure TScroll.SetVisible(Value: Boolean);
begin
if Value = True
then
begin
FVisible := Value;
end;
if FLength = 0
then
FLength := 100;
// SendMessage(FHandle, LB_SetHorizontalExtent,FLength,Longint(0));
{ Handle undefiniert !!!!! }
end;
{ ----------------------------------------------------------------------------- }
procedure MyColorListBox1.SetScrollBar(Value: TScroll);
begin
if Value.FVisible = True
then
begin
FScrollbar := Value;
if Value.FLength = 0
then
Value.FLength := 10;
SendMessage(
Handle, LB_SetHorizontalExtent,Value.FLength,Longint(0));
end;
end;
{ ----------------------------------------------------------------------------- }
end.