unit MyPanel_1;
interface
uses
SysUtils , Classes, Controls, ExtCtrls,
StdCtrls ,
Dialogs ,
Graphics ;
type
TMyPanel =
class(TPanel)
private { Private-Deklarationen }
bDown : boolean ;
L1 : TLabel ;
L2 : TLabel ;
L3 : TLabel ;
xL1_Top : integer ;
xL1_Left : integer ;
xL1_Width : integer ;
xL1_Height : integer ;
xL1_Color : TColor ;
xL1_FontName : TFontName ;
xL1_FontColor : TColor ;
xL1_FontSize : integer ;
xL1_Caption : TCaption ;
constructor Create(AOwner: TComponent) ;
override ;
destructor Destroy ;
override ;
procedure Click ;
override ;
procedure SetState(bValue : boolean );
procedure Set_L1_Color(yL1_Color : TColor );
procedure Set_L1_FontColor(yL1_FontColor : TColor );
procedure MyLabelOnClick(Sender: TObject);
// von dem Unwissenden #4
protected { Protected-Deklarationen }
public { Public-Deklarationen }
published { Published-Deklarationen }
property L1_Top : integer
read xL1_Top
write xL1_Top ;
property L1_Left : integer
read xL1_Left
write xL1_Left ;
property L1_Width : integer
read xL1_Width
write xL1_Width ;
property L1_Height : integer
read xL1_Height
write xL1_Height ;
property L1_Color : TColor
read xL1_Color
write Set_L1_Color ;
//xL1_Color ;
property L1_FontName : TFontName
read xL1_FontName
write xL1_FontName ;
property L1_FontColor : TColor
read xL1_FontColor
write Set_L1_FontColor ;
//xL1_FontColor ;
property L1_FontSize : integer
read xL1_FontSize
write xL1_FontSize ;
property L1_Caption : TCaption
read xL1_Caption
write xL1_Caption ;
property Down : boolean
read bDown
write SetState ;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('
Dirk_2', [TMyPanel]);
end;
constructor TMyPanel.Create(AOwner: TComponent);
begin
inherited create(AOwner) ;
L1 := TLabel.Create(self);
L1.Parent := self ;
L1.Visible := TRUE ;
L1.OnClick := Self.MyLabelOnClick ;
// von dem Unwissenden #4
xL1_Left := 30 ;
xL1_Top := 30 ;
xL1_Height := 30 ;
xL1_Width := 90 ;
xL1_Color := clGreen ;
xL1_FontName := '
Arial' ;
xL1_FontColor := clRed ;
xL1_FontSize := 8 ;
xL1_Caption := '
L1 = Label1' ;
L1.AutoSize := FALSE ;
// Festgeschrieben nicht änderbar !!
L1.Left := xL1_Left ;
L1.Top := xL1_Top ;
L1.Height := xL1_Height ;
L1.Width := xL1_Width ;
L1.Color := xL1_Color ;
L1.Font.
Name := xL1_FontName ;
L1.Font.Color := xL1_FontColor ;
L1.Font.Size := xL1_FontSize ;
L1.Caption := xL1_Caption ;
//==================================
L2 := TLabel.Create(self);
L2.Parent := self ;
L2.Visible := TRUE ;
L2.Left := 30 ;
L2.Top := 30 ;
L2.Height := 10 ;
L2.Width := 10 ;
L2.Caption := '
NEU' ;
end;
procedure TMyPanel.MyLabelOnClick;
begin
Click ;
// geht wie self.Click;
//self.Click; // geht auch
//click(self); // geht nicht von daddy # 11 --> [Pascal Fehler] Switch.pas(125): E2034 Zu viele Parameter
{ // geht nicht von dem Unwissenden #4
if Assigned(Self.OnClick) then
begin
self.OnClick;
end;
}
end;
destructor TMyPanel.Destroy ;
begin
L1.Free ;
L2.Free ;
L3.Free ;
inherited destroy ;
end;
procedure TMyPanel.Set_L1_Color(yL1_Color : TColor );
begin
xL1_Color := yL1_Color ; L1.Color := xL1_Color ;
end;
procedure TMyPanel.Set_L1_FontColor(yL1_FontColor : TColor );
begin
xL1_FontColor := yL1_FontColor ; L1.Font.Color := xL1_FontColor ;
end;
procedure TMyPanel.Click ;
begin
if BevelOuter = bvRaised
then
begin
BevelOuter := bvLowered ;
bDown := TRUE ;
end
else
begin
BevelOuter := bvRaised ;
bDown := FALSE ;
end;
inherited Click ;
end;
procedure TMyPanel.SetState(bValue: Boolean);
begin
if bValue = TRUE
then
begin
bDown := TRUE ;
BevelOuter := bvLowered ;
end
else
begin
bDown := FALSE ;
BevelOuter := bvRaised ;
end;
end;
end.