unit mSchalter;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,mPanelDemo, StdCtrls, Buttons, mTaster1;
type
TForm1 =
class(TForm)
BtGruenPanel: TButton;
procedure BtGruenPanelClick(Sender: TObject);
private
{ Private-Deklarationen }
Gedrueckt: Boolean;
public
{ Public-Deklarationen }
constructor Create (AOwner:TComponent; Farbe:TColor);
override;
end;
type
TBuntSchalter =
Class (TBuntPanel)
protected
procedure MouseDown (Button: TMouseButton; Shift: TShiftState; X,Y: Integer);
override;
procedure MouseUp (Button: TMouseButton; Shift: TShiftState; X,Y: Integer);
override;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BtGruenPanelClick(Sender: TObject);
var GruenPanel: TGruenPanel;
MyBuntSchalter: TBuntSchalter;
begin
GruenPanel:=TGruenPanel.Create(Form1);
GruenPanel.Parent:=Form1;
GruenPanel.Left:=200;
GruenPanel.Height:=50;
MyBuntSchalter:=TBuntSchalter.Create(Form1);
MyBuntSchalter.Parent:=Form1;
MyBuntSchalter.BringToFront;
end;
procedure TBuntSchalter.MouseDown (Button: TMouseButton; Shift: TShiftState; X,Y: Integer);
begin
if Gedrueckt
then begin
BevelOuter := bvRaised;
Caption := '
aus';
inherited MouseUp (Button,Shift,X,Y)
end
else begin
BevelOuter := bvLowered;
Caption := '
an';
inherited MouseDown (Button, Shift,X,Y);
end;
Gedrueckt :=
Not Gedrueckt;
end;
procedure TBuntSchalter.MouseUp (Button: TMouseButton; Shift: TShiftState; X,Y: Integer);
begin
end;
constructor TBuntSchalter.Create(AOwner:TComponent; Farbe:TColor);
begin
inherited Create(AOwner, Farbe);
Caption := '
aus';
Gedrueckt := False;
end;
end.