TSechsEck =
class(TCustomControl)
protected
procedure SetParent(AParent: TWinControl);
override;
public
constructor Create(AOwner: TComponent);
override;
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
override;
end;
constructor TSechsEck.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Color := clBlue;
SetBounds(Left, Top, 100, 100);
end;
procedure TSechsEck.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
var LPoints:
Array[0..5]
of TPoint;
LPart: Integer;
begin
if Assigned(Parent)
then
begin
LPart := Round(AHeight / 4);
LPoints[0] := Point(AWidth
div 2 - 1, 0);
LPoints[1] := Point(AWidth - 1, LPart);
LPoints[2] := Point(AWidth - 1, LPart * 3);
LPoints[3] := Point(AWidth
div 2 - 1, AHeight - 1);
LPoints[4] := Point(0, LPart * 3);
LPoints[5] := Point(0, LPart);
SetWindowRgn(
Handle, CreatePolygonRgn(LPoints, length(LPoints), ALTERNATE), True);
end;
inherited SetBounds(ALeft, ATop, AWidth, AHeight);
end;
procedure TSechsEck.SetParent(AParent: TWinControl);
begin
inherited SetParent(AParent);
if Assigned(Parent)
then
SetBounds(Left, Top, Width, Height);
end;