unit MyButtons;
interface
uses
SysUtils, Classes, Controls, Graphics;
type
Wechselbutton =
class(TCustomControl)
private
{ Private-Deklarationen }
FOnMouseDown :TMouseEvent;
Img_normal :TBitmap;
Img_MouseDown :TBitmap;
Img_disabled :TBitmap;
b_Enabled :Boolean;
b_MouseDown :Boolean;
protected
{ Protected-Deklarationen }
Procedure Paint;
override;
Procedure SetNormImg(Img :TBitmap);
Procedure SetMoDoImg(Img :TBitmap);
Procedure SetDisaImg(Img :TBitmap);
public
{ Public-Deklarationen }
constructor Create(Owner: TComponent);
override;
published
{ Published-Deklarationen }
Property OnMouseDown:TMouseEvent
read FOnMouseDown
write FOnMouseDown;
Property Surface_Normal :TBitmap
read Img_normal
write SetNormImg;
Property Surface_MouseDown :TBitmap
read Img_MouseDown
write SetMoDoImg;
Property Surface_Disabled :TBitmap
read Img_disabled
write SetDisaImg;
end;
procedure Register;
implementation
constructor Wechselbutton.Create(Owner: TComponent);
begin
inherited Create(Owner);
b_Enabled := True;
b_MouseDown := False;
Img_normal := TBitmap.Create;
Img_MouseDown := TBitmap.Create;
Img_disabled := TBitmap.Create;
end;
procedure Wechselbutton.Paint;
begin
If b_Enabled
then
Begin
If b_MouseDown
then
Begin
{Width := Img_MouseDown.Width;
Height := Img_MouseDown.Height; }
Canvas.Draw(0,0,Img_MouseDown);
End
Else
Begin
{Width := Img_normal.Width;
Height := Img_normal.Height;}
Canvas.Draw(0,0,Img_normal);
End;
End
Else
Begin
Width := Img_disabled.Width;
Height := Img_disabled.Height;
Canvas.Draw(0,0,Img_disabled);
End;
end;
Procedure Wechselbutton.SetNormImg(Img :TBitmap);
begin
if Img <> Img_normal
then
begin
Img_normal.Assign(Img);
Update;
end;
end;
Procedure Wechselbutton.SetMoDoImg(Img :TBitmap);
begin
if Img <> Img_MouseDown
then
begin
Img_MouseDown.Assign(Img);
Update;
end;
end;
Procedure Wechselbutton.SetDisaImg(Img :TBitmap);
begin
if Img <> Img_disabled
then
begin
Img_disabled.Assign(Img);
Update;
end;
end;
//*****************
//*****************
//*****************
procedure Register;
begin
RegisterComponents('
Beispiele', [MyButtons.Wechselbutton]);
end;
end.