Registriert seit: 16. Nov 2005
51 Beiträge
Delphi 2005 Personal
|
Re: komponente erstellen
6. Dez 2005, 18:42
Also ich habe es geknackt:
Delphi-Quellcode:
unit Switch;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TSwitch = class(TPanel)
constructor Create(AOwner: TComponent); override;
private
bDown : boolean;
bHeight : Integer;
bVisina : Integer;
labeli : TLabel;
procedure Click;
procedure SetState(bValue: boolean);
protected
{ Protected-Deklarationen}
public
{ Public-Deklarationen}
published
property Down : Boolean read bDown write SetState;
property Visina1: Integer read bHeight write bHeight;
property Visina2: Integer read bVisina write bVisina;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents(' Beispiele', [TSwitch]);
end;
constructor TSwitch.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
labeli := TLabel.Create(Self);
labeli.Parent := Self;
labeli.Top := Self.Top;
labeli.Left := Self.Left;
labeli.Caption := ' test';
labeli.Visible := true;
end;
procedure TSwitch.Click;
begin
if bHeight = Height then
begin
Height := bVisina;
bDown := true
end
else
begin
Height := bHeight;
bDown := false
end;
end;
procedure TSwitch.SetState(bValue: boolean);
begin
if bValue = true then
begin
bDown := true;
Height := bVisina;
end
else
begin
bDown := false;
Height := bHeight;
end
end;
end.
Danke MarcoWarm für die Idee mit Constructor!!!!
Milan
|
|
Zitat
|