procedure Register;
begin
RegisterComponents('Samples', [TTitlePanel]);
end;
{ TTitlePanel }
procedure TTitlePanel.CloseBtnClick(Sender: TObject);
begin
Visible:=False;
if Assigned(FOnClose) then FOnClose(Sender);
end;
constructor TTitlePanel.Create(AOwner: TComponent);
begin
inherited;
HTopPanel:=TPanel.Create(Self);
with HTopPanel do
begin
Height:=24;
Align:=alTop;
Parent:=Self;
BevelInner:=bvLowered;
end;
HCloseBtn:=TBitBtn.Create(HTopPanel);
with HCloseBtn do
begin
Top:=1;
Left:=1;
Width:=22;
Height:=22;
Kind:=bkCancel;
Caption:='';
Parent:=HTopPanel;
OnClick:=CloseBtnClick;
end;
HTitleLabel:=TLabel.Create(HTopPanel);
with HTitleLabel do
begin
Top:=2;
Left:=25;
Parent:=HTopPanel;
Caption:=FTitle;
end;
end;
procedure TTitlePanel.CreateParams(var Params: TCreateParams);
const
BorderStyles: array[TBorderStyle] of DWORD = (0, WS_BORDER);
begin
inherited CreateParams(Params);
FTitle:=Params.Caption;
HtitleLabel.Caption:=FTitle;
Params.Caption:='';
end;
function TTitlePanel.GetTitleFont: TFont;
begin
Result:=HTitleLabel.Font;
end;
procedure TTitlePanel.SetOnClose(const Value: TNotifyEvent);
begin
FOnClose := Value;
end;
procedure TTitlePanel.SetTitle(const Value: String);
begin
FTitle := Value;
HtitleLabel.Caption:=FTitle;
end;
procedure TTitlePanel.SetTitleFont(const Value: TFont);
begin
HTitleLabel.Font.Assign(Value);
end;