unit TestColorChange;
interface
uses
SysUtils, Classes, Controls, ExtCtrls, StdCtrls, uTestFormColorChange ;
type
TTestColorChange =
class(TCustomControl)
private
{ Private-Deklarationen }
CCEdit : TEdit ;
CCButton : TButton ;
CCShape : TShape ;
Fenster : TTestFormColorChange ;
FOnChange: TNotifyEvent;
procedure ButtonClick(Sender: TObject);
procedure EditChange(Sender: TObject);
protected
{ Protected-Deklarationen }
public
{ Public-Deklarationen }
constructor Create( AOwner: TComponent);
Override;
destructor Destroy;
override;
published
{ Published-Deklarationen }
property OnChange: TNotifyEvent
read FOnChange
write FOnChange;
end;
procedure Register;
implementation
constructor TTestColorChange.Create(AOwner: TComponent);
begin
RegisterClass(TTestFormColorChange);
inherited Create(AOwner);
Fenster := TTestFormColorChange.Create(Owner);
CCEdit := TEdit.Create(Self);
CCButton := TButton.Create(Self);
CCShape := TShape.Create(Self);
insertcontrol(CCEdit);
insertcontrol(CCButton);
insertcontrol(CCShape);
CCEdit.
Name :=
name + '
Edit';
CCEdit.Top := 1 ;
CCEdit.Left := 1 ;
CCEdit.Text :=
name ;
CCEdit.OnChange := EditChange ;
CCButton.
Name :=
Name + '
Button' ;
CCButton.Left := CCEdit.Width +1 ;
CCButton.Top := 1 ;
CCButton.Height := CCEdit.Height +1 ;
CCButton.Width := CCButton.Height ;
CCButton.Caption := '
...';
CCButton.OnClick := ButtonClick ;
CCShape.
Name :=
Name + '
Shape';
CCShape.Top := CCEdit.Height+3 ;
CCShape.Left := 1 ;
CCShape.Height := CCEdit.Height ;
CCShape.Width :=CCEdit.Width + CCButton.Width;
height := ( CCEdit.Height * 2 ) + 5 ;
width := CCShape.Width + 2 ;
end;
destructor TTestColorChange.Destroy;
begin
CCShape.Free;
CCButton.Free;
CCEdit.Free;
Fenster.Destroy ;
inherited Destroy;
end;
procedure TTestColorChange.EditChange(Sender: TObject);
begin
if Assigned(FOnChange)
then FOnChange(self);
end;
procedure TTestColorChange.ButtonClick(Sender: TObject);
var tmp :
string ;
begin
tmp := CCEdit.text ;
if Fenster.Execute( tmp )
then
begin
CCEdit.text := tmp ;
end;
end;
procedure Register;
begin
RegisterComponents('
MyTools', [TTestColorChange]);
end;
end.